Displaying a About dialog – C#

Every business application requires a about box. You can display static values here or retrieve them from your assembly and display at runtime. There also many ways to deploy your application to the end-user. In case, you use click-once, then you may want to display the publish version rather than the assembly version in your about box.

Here, I am explaining you how to retrieve such information from your assembly and version from your click-once publish and display at runtime.



Assembly assembly = Assembly.GetExecutingAssembly();
// name, description and more
object[] attributes = assembly.GetCustomAttributes(true);
foreach (object attribute in attributes)
{
	if (attribute is AssemblyTitleAttribute)
		lblAppName.Text = ((AssemblyTitleAttribute)attribute).Title;
	//similar to this, you can also extract company name, copyright etc.
}

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
	//This application was deployed using click-once publish. So display publish version
	lblVersion.Text = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
	hypUrl.Text = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdateLocation.OriginalString;
}
else
{
	// assembly version
	AssemblyName assemblyname = assembly.GetName();
	Version assemblyver = assemblyname.Version;
	lblVersion.Text = assemblyver.ToString();
	hypUrl.Visible = false;
}


Share This

Leave a Reply

Your email address will not be published. Required fields are marked *


three × = 24