Assembly version?
-
How to get the assembly version in C#? I mean it is easy to get it for the assembly from which the code is executing by using the GetExecutingAssembly(), but how to get it for any other assembly? Thanks.
Is the assembly loaded? If so, the current AppDomain should be able to retrieve it using
GetAssemblies
, in which case you could just check the version property. Otherwise, you could load it usingAssembly.Load
orAssembly.LoadFrom
.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
Is the assembly loaded? If so, the current AppDomain should be able to retrieve it using
GetAssemblies
, in which case you could just check the version property. Otherwise, you could load it usingAssembly.Load
orAssembly.LoadFrom
.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
Exactly my point. Now why in the Earth I need to load the whole assembly to get it version? Seems little bit clumsy, doesn't it?
Look at the C# spec then to read the assembly manually. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
-
Exactly my point. Now why in the Earth I need to load the whole assembly to get it version? Seems little bit clumsy, doesn't it?
Clumsy? No, not really. My assumption was that you were interested in using the assembly in some way versus just inspecting its version. If all you want is the version, and nothing else, I would advise using the
System.Diagnostics.FileVersionInfo
class.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
Clumsy? No, not really. My assumption was that you were interested in using the assembly in some way versus just inspecting its version. If all you want is the version, and nothing else, I would advise using the
System.Diagnostics.FileVersionInfo
class.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’