Reading version from other assembly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It seems easy to read the version info from the current assembly. I need to
read the version info from a different assembly and am not clear how to do it.

Thanks in advance!
 
Dim asm As System.Reflection.Assembly = _
System.Reflection.Assembly.LoadFrom("C:\Other.Assembly.dll")

Dim asmVersion As System.Version = asm.GetName.Version
Console.WriteLine(asmVersion.ToString)

Take a look at the Load, LoadFrom and LoadWithPartialName shared methods of
the System.Reflection.Assembly class to load an assembly and then you can
retrieve all the information from the assembly just like you would do for
the current assembly.


hope that helps...
Imran.
 
this will load the assembly into the current AppDomain. If you simply want to find out the version, without loading the assembly (the file will still be read but not loaded into the AppDomain), use:

AssemblyName n = AssemblyName.GetAssemblyName(@"C:\Other.Assembly.dll");

Console.WriteLine(n.Version);

Regards

Richard Blewett -- DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<[email protected]>

Dim asm As System.Reflection.Assembly = _
System.Reflection.Assembly.LoadFrom("C:\Other.Assembly.dll")

Dim asmVersion As System.Version = asm.GetName.Version
Console.WriteLine(asmVersion.ToString)

Take a look at the Load, LoadFrom and LoadWithPartialName shared methods of
the System.Reflection.Assembly class to load an assembly and then you can
retrieve all the information from the assembly just like you would do for
the current assembly.


hope that helps...
Imran.

Steve Kallal said:
It seems easy to read the version info from the current assembly. I need to
read the version info from a different assembly and am not clear how to do it.

Thanks in advance!



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004



[microsoft.public.dotnet.framework]
 
yup -definitely a more efficient (and cleaner) solution.

Imran.

Richard Blewett said:
this will load the assembly into the current AppDomain. If you simply want
to find out the version, without loading the assembly (the file will still
be read but not loaded into the AppDomain), use:

AssemblyName n = AssemblyName.GetAssemblyName(@"C:\Other.Assembly.dll");

Console.WriteLine(n.Version);

Regards

Richard Blewett -- DevelopMentor

http://staff.develop.com/richardb/weblog


nntp://news.microsoft.com/microsoft.public.dotnet.framework/<[email protected]>

Dim asm As System.Reflection.Assembly = _
System.Reflection.Assembly.LoadFrom("C:\Other.Assembly.dll")

Dim asmVersion As System.Version = asm.GetName.Version
Console.WriteLine(asmVersion.ToString)

Take a look at the Load, LoadFrom and LoadWithPartialName shared methods
of
the System.Reflection.Assembly class to load an assembly and then you can
retrieve all the information from the assembly just like you would do for
the current assembly.


hope that helps...
Imran.

Steve Kallal said:
It seems easy to read the version info from the current assembly. I need to
read the version info from a different assembly and am not clear how to
do it.

Thanks in advance!



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004



[microsoft.public.dotnet.framework]
 
Back
Top