Is it possible to load an .net 4.0 application inside a .net 3.5 application using containers?
Asked Answered
S

1

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?

Sherrisherrie answered 19/2, 2014 at 22:19 Comment(1)
That's not possible. Just write a .config file that forces CLR v4 to be used instead, <supportedRuntime> element.Taliataliaferro
B
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:

Bab answered 23/2, 2014 at 21:33 Comment(3)
It is possible to host two CLRs at once, and has been since v4.0 came out, though this is still the better idea.Nationality
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.Bab
Just found this Channel 9 video on the topic (although I've not reviewed yet): channel9.msdn.com/Shows/Going+Deep/…Bab

© 2022 - 2024 — McMap. All rights reserved.