views:

410

answers:

3

From the command line (or by any means really), how can I determine which clr version a .net assembly requires? I need to determine if an assembly requires 2.0 or 4.0 clr version.

+6  A: 

ildasm.exe will show it if you double-click on "MANIFEST" and look for "Metadata version". By default, it's the version that the image was compiled against.

Darin Dimitrov
Thanks a lot :-)
klausbyskov
+5  A: 
class Program {
  static void Main(string[] args) { 
      System.Console.WriteLine(
             System.Reflection.Assembly.LoadFrom(args[0]).ImageRuntimeVersion);
  }
}

Compile and run the above application under the latest .NET Framework (as an older CLR may be unable to load assemblies requiring a newer CLR) and run it passing the path to the assembly you want to check as the command line argument.

Mehrdad Afshari
+1 Thank you. That is useful for automations.
klausbyskov
+2  A: 

From command line

DUMPBIN your dll/exe /CLRHEADER

Tinku
interesting, thanks.
klausbyskov