3

I have a c# project I am converting from .net 3.5 to .net 4.0 in VS2010. It has references to other 3rd party dll's that have a runtime version of v2.0.50727.

How can this be? I kind of expected a warning or breakage when building or running, but I haven't. If my compiled .net 4 project is running with the .net v4.0.30319 runtime, is it running the referenced dll with the .net 2.0.50727 runtime? And therefore, I still need old versions of .net installed?

Or is the referenced dll running in the v4.0.30319 runtime?

  • Please see this question: [Link here][1] [1]: http://stackoverflow.com/questions/8373541/old-library-written-in-net-framework-2-use-in-net-4 – Oliver Kane Sep 18 '13 at 14:31
  • Thanks for all the great responses! I also found my answer here - http://stackoverflow.com/questions/6216599/does-using-assembly-compiled-in-older-version-of-net-framework-affects-whole-pe – Aaron Morrison Sep 18 '13 at 14:57

2 Answers2

5

No, that just works automagically. The v4 CLR has no trouble with old v2 assembly references, it translates them one-to-one to the v4 versions of those assemblies. Or if this is a non-framework assembly then nothing magically happens, it can still read the metadata of a v2 assembly.

Rather necessary, few programmers would have opted to move up to version 4.0 if that wouldn't work. There have been a few isolated cases where a over-due bug fix in 4.0 caused different behavior but they have been very rare.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • The v4 CLR will not run the v2 assemblies. You must have the v2 CLR installed. See my answer for more details. – Phillip Scott Givens Sep 19 '13 at 01:48
  • No. The inprocess side-by-side feature is only enabled for custom CLR hosting scenarios. A [ComVisible] .NET assembly getting loaded into an unmanaged process is the most common case. – Hans Passant Sep 21 '13 at 13:26
0

From the commented question to prevent link rot:

"Yes, you can reference a 2.0 class library from an application of a higher framework version, but not the other way around.

You can always check the .NET Version Compatibility. (There are some caveats moving to 4, but generally speaking you should be fine.) --Brad Christie

Any problems you might see would arise from a version previous to 2. (Though I hear past 4 is a re-write, so I'm not sure how they are handling backwards compatibility. I'm sure they have to keep it safe, as no many people want to side-load two .net versions" --wsanville

What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

Community
  • 1
  • 1
Oliver Kane
  • 888
  • 1
  • 6
  • 23