Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change AssemblyBuilder ImageRuntimeVersion

Tags:

c#

.net

Is it possible to dynamically create an assembly that targets a different runtime from the current AppDomain.

For example, from within a .NET 4.0 application I want to create a new assembly that targets .NET 2.0 instead.

AssemblyBuilder builder = Thread.GetDomain().DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
var version = builder.ImageRuntimeVersion; //"v4.0.30319"
like image 652
Peervm Avatar asked Jul 12 '11 07:07

Peervm


Video Answer


1 Answers

If it still needed I found the following example:

MSDN Blog- Targeting the .NET 2 Framework when using AssemblyBuilder under .NET 4

Seems like you have to use the CLR native API.

like image 90
Orri Avatar answered Oct 04 '22 13:10

Orri