Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

mef

maf

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?

like image 919
Prince Ashitaka Avatar asked Feb 19 '14 22:02

Prince Ashitaka


1 Answers

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:

  • Channel 9 - Rick Byers and Simon Hall: CLR 4 - Side-by-Side In-Process - What. How. Why.
  • MSDN Magazine: In-Process Side-by-Side
  • Distributed Matters - Loading multiple CLR Runtimes (InProc SxS) – Sample Code
like image 106
Matt Tester Avatar answered Nov 13 '22 06:11

Matt Tester