0
votes

There is a lot of mismash of information out there regarding which version of the CLR an assembly will be loaded into so in hope to consolidate some answers to disambiguate the questions that follow in relation to CLR version

  • When I am targeting version 4 of the .Net Framework and building in VS2010 will I be using clr version 4? What version of the CLR will the assemblies that I reference use if I do not add any config in my app.config file?

  • Can I force my application to use a different version of the CLR? If yes, how?

  • When I am targeting version 2 or 3.5 of the .Net Framework and building in VS2010, which clr version will the compiled assemblies be using?

  • What version of the CLR will the assemblies that I reference use if I do not add any config in my app.config file?

  • Can I force my application to use a different version of the CLR, (e.g version 4)? If yes, how?

  • Is it safe to reference v2 assemblies in a new project that targets v4? Why?

1
The topic may be complex, but questions are all related. Splitting it up in separate questions is only going to make it more difficult to see the big picture answer in my humble opinion. I'm in no rush for the answer myself and it would be good to get some overall clarity on this topic by having all these related answers in the same thread. Surely a topic like this would be a good candidate for community wiki?Anastasiosyal
We don't really do wikis anymore. They're legit questions, its just that you cannot reasonably answer them all within a single answer. And they aren't all that related. Take the last two for example. Actually, now that I look, it appears two and five are the same. Please consider editing to just ask the first question.user1228

1 Answers

2
votes

When I am targeting version 4 of the .Net Framework and building in VS2010 will I be using clr version 4?

Yes.

Can I force my application to use a different version of the CLR? If yes, how?

No, there is no other version available that can run a program that targets 4.0. The next framework version (4.5) will not be a side-by-side version so uses the same CLR, it is impossible to look beyond that.

When I am targeting version 2 or 3.5 of the .Net Framework and building in VS2010, which clr version will the compiled assemblies be using?

Version 2.0.50727, it must be present on the machine

What version of the CLR will the assemblies that I reference use if I do not add any config in my app.config file?

Version 2.0.50727 when you target any framework version between 2.0 and 3.5, version 4.0.30319 when you target 4.0

Can I force my application to use a different version of the CLR, (e.g version 4)? If yes, how?

Use the <supportedRuntime version="v4.0"/> element in the .exe.config file.

is it safe to reference v2 assemblies in a new project that targets v4? Why

Yes. It is only unsafe to not test this scenario, there might be a fix for a framework bug that you accidentally relied on.