Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top