9

Is it possible to load an .net 4.0 application inside .net 3.5 application using containers such as MEF or MAF?

I'm aware of the fact that only backward compatibility is supported in.net, will that make any difference in containers?

Prince Ashitaka
  • 8,623
  • 12
  • 48
  • 71

1 Answers1

3

It is not possible. When the application loads, it will be using CLR v2.0 (.NET 3.5). The .NET 4.0 assembly requires the use of CLR v4.0 and since it is not possible for an application to host two CLRs at once, you won't have much luck regardless of how the assemblies are loaded.

Your best option is to start the application with CLR v4.0:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
</startup>

Edit

Based on the comment by Jon Hanna, it turns out "not possible" is too strong a phrase. There is something called "CLR In-Process Side-by-Side" which is part of .NET 4. I'd still recommend my original answer, but more info on this can be found at:

Matt Tester
  • 4,663
  • 4
  • 29
  • 32
  • It is possible to host two CLRs at once, and has been since v4.0 came out, though this is still the better idea. – Jon Hanna Feb 23 '14 at 22:59
  • That's interesting! Have you got a link available with a bit of detail in it - it can be added as an option in the answer. – Matt Tester Feb 23 '14 at 23:05
  • 1
    Just found this Channel 9 video on the topic (although I've not reviewed yet): http://channel9.msdn.com/Shows/Going+Deep/CLR-4-Side-by-Side-In-Process-What-How-Why – Matt Tester Feb 23 '14 at 23:07