tags:

views:

180

answers:

3

I have a program which I believe to be running in .NET 4.0, but I am unable to mixed-mode debug it (something new .net 4.0 for 64-bit application)

I wanted to confirm if I'm truly running in .NET 4.0 or is it running .NET 3.5

Is there a way to look in the memory space or something?

+7  A: 

Different options are:

  • Check the value of Environment.Version
  • typeof (int).Assembly.GetName ().Version: this will give you the running mscorlib.dll assembly version.
  • Use Process Explorer if you can't change the code. Then check which version of mscorlib is loaded and from where.
Gonzalo
Note though that this will return which version of the *CLR* that the program is running on. I can't verify it right now, but that should mean that it reports 2.0 both for apps running on .NET framework 2 and 3.5. .NET framework 4 comes with a new CLR, so that can be confirmed by checking the CLR version in use.
Fredrik Mörk
Is there a less invasive way of doing this? As in I do have sources, but I'll have to copy the entire tree down, and I'm roaming, not @ work so another solution would be helpful but I can try.
halivingston
Yes, there is. Give me a minute to find the link.
Gonzalo
Done. Added as 3rd option.
Gonzalo
Thanks, that worked beautifuly!
halivingston
+1 for giving several solutions to the problem.
Nestor
+1  A: 

typeof(int).Assembly.ImageRuntimeVersion will give you the version of the mscorlib assembly loaded in your process.

logicnp
A: 

This returns the .Net runtime version as a string:

System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()

You can also get the install directory as well:

System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()

goto msdn

csharptest.net