Hannes Pavelka
It isn't rocket science. Well, unless of course you're NASA

How to determine which clr version an assembly or executable is using

Saturday, December 30, 2006 12:19 AM

Let’s assume you have all (most) of the framework versions installed on your machine.
How can you determine which application uses which framework version ?

Reminder: There is plenty of information about how to determine which framework version is installed.
The question at hand, is about which framework version does an application actually use !
Microsoft published an kb about  :
How to determine which versions of the .NET Framework are installed and whether service packs have been applied
For your information, here is a full list of version numbers:

However, most people just differentiate between v. 1.0/1.1 (what they mean is 1.1.4322.2032) and v 2.0 (which is 2.0.50727.42).


Now back to the original question. How can you determine what framework version an application uses ?

There is an tool called clrver.exe which is shipped with the SDK for .Net 2.0 , you can find the tool under C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin

If you use the clrver.exe tool without arguments you get the following output:
C:\Programme\Microsoft Visual Studio 8\VC>clrver.exe
Versions installed on the machine:
v2.0.50727
You can use all / <pid> argument to get more detailed information.
-all   - Displays all processes on the machine using the CLR.
<PID> - Displays the version of the CLR used by the specified process.

Thus you can get detail information about the running processes.

3920    devenv.exe              v2.0.50727
2084    WebDev.WebServer.EXE    v2.0.50727
2944    Obab.UI.ProfessorenClientCab.vshost.exe v2.0.50727

Unfortunatley, you can only get the information from running applications. There is no way to let clrver.exe determine the required/used framework version from the application file itself.

Over at Devfish , you find an interesting arcticle  about the above topic and what is more important, you can even download a simple tool to determine the version information directly from a file.You pass that tool a filename and it outputs the Version information and what version of the CLR runtime the file requires. The source code for that tool can be found here.

I wonder why clrver.exe does not supply this functionality out-of-the-box ?


Feedback

# re: How to determine which clr version an assembly or executable is using

Does anyone know if a way to scan an entire drive and see which exe's use .net 1.0 or .net 2.0? 6/28/2007 4:00 AM | bob

# re: How to determine which clr version an assembly or executable is using

This can also be done by using corflags.exe (supplied with vs2005) 5/22/2008 8:23 PM | M

# re: How to determine which clr version an assembly or executable is using

This can also be done by using corflags.exe (supplied with vs2005) 5/22/2008 8:24 PM | M

# re: How to determine which clr version an assembly or executable is using

One of the reasons why I think it doesn't make sense to show which version of clr a file uses until you run it is because, consider an example of a managed com component that is compiled against v2 and called from a process or a host that is running against v4. In this case, it can be found out that the v4 app requires clr4 but until it executes and loads v2 managed com compoenent, v4 itself has no idea about it. makes sense? 8/6/2009 1:46 AM | Sarang

Post a comment