问题
I need to dynamically create a .NET 2.0 compatible assembly from within my .NET 4.0 process. Currently it is achieved with this:
AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(...)
ModuleBuilder mb = assemblyBuilder.DefineDynamicModule(...);
But unfortuntely all dll's produced are .NET 4.0 (inherited from my 4.0 process) which doesn't work with my other .NET 2.0 processes.
Any idea how 2 different CLR versioned AppDomains can co-exist in the same process?
回答1:
Have a look at this question: http://social.msdn.microsoft.com/Forums/en/clr/thread/1bfd7f40-fd57-4c9f-803f-aa4b19214af9.
Paul Zhou explains, that it is possible to host multiple CLRs in the same Windows process and provides the following links with more detailed information:
- CLR Hosting APIs
- Creating a host application for the .NET Common Language Runtime
- Host CLR
However, the links look like this is not exactly a trivial task...
来源:https://stackoverflow.com/questions/6689318/create-net-2-0-appdomain-in-net-4-0-process