Reputation: 1903
We have a large solution with about 30 projects. We also have some common code utilities and as part of that utility class we have included a GetAssemblyVersionInfo
method that returns the version info of that assembly. However, we want to get the Assembly Version Info of the assembly for the project not the utility DLL. Is there any way of having a utility function that returns the version info of another assembly based on execution and not passing around filenames?
EDIT:
For those who are curious, I solved it using:
System.Reflection.Assembly.GetCallingAssembly().GetName().Version
Upvotes: 1
Views: 2904
Reputation: 31641
If you have the assembly name, you can dynamically load it into the current AppDomain to retrieve the version info.
Assembly.LoadFrom(string.Format("{0}.dll", "assemblyshortname")).GetName().Version
Upvotes: 1
Reputation: 27343
I think you should use GetEntryAssembly()
instead of GetCallingAssembly()
.
Upvotes: 0