Reputation: 113
I have .NET 6.0 app which dynamically loads .NET Framework 4.8 assembly. Calling method from this assembly with reflection throws this exception:
System.MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.
By including a reference to System.Reflection.Emit, I found out that method DefineDynamicAssembly
does not exist in AppDomain
in .NET Core. Loaded assembly calls AppDomain.CurrentDomain.DefineDynamicAssembly()
and failing to find the method throws exception.
So I decided to add this new method dynamically in runtime and unsuccessfully tried two following approaches:
TypeBuilder
from ModelBuilder.DefineType()
which defines a new type but I need to hook up to the existing instance of AppDomain.CurrentDomain
;Is there any other way to solve this problem? Or maybe I am missing something in the above approaches? I will appreciate any advice!
Upvotes: 1
Views: 376