It is trivial to get Assembly information at run-time using reflection:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
However, I cannot use reflection in my project due to restricted execution environment. In limited trust environment this code will not work.
I want to use some attributes from AssemblyInfo.cs
at compile time to show product name, version etc. without invoking reflection mechanism.
Most primitive way would be just duplicating strings from AssemblyInfo.cs
file as constant strings somewhere else. But maybe there exist some more elegant solutions?
Of course, some essential info on assembly can be properly resolved only at run-time through reflection. Say, assembly path, execution context etc. But info about name and version is written in project code and should be normally available at compile time.
Any comments and ideas are appreciated. Thank you.