Monday, December 22, 2008

Read AssemblyInfo file in runtime

Sometime we need to read the information which is there in the assemblyinfo.cs file for about formbox. I googled in internet, finally found an answer.

Assembly currentAssembly = Assembly.GetExecutingAssembly();

AssemblyName assemblyName = currentAssembly.GetName();

//If only need version information then use.
assemblyName.Version.ToString();

//Copyright information
AssemblyCopyrightAttribute copyright =
AssemblyCopyrightAttribute.GetCustomAttribute(currentAssembly,
typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;

like this you can get all the attribute information from assemblyinfo.cs file.

AssemblyVersionAttribute
AssemblyProductAttribute
AssemblyDescriptionAttribute
AssemblyCompanyAttribute
AssemblyTitleAttribute

If you need any more information feel free contact me at any time.

No comments: