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

StackOverflow https://stackoverflow.com/questions/21893788

  •  13-10-2022
  •  | 
  •  

質問

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?

役に立ちましたか?

解決

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:

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top