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