jeudi 27 janvier 2022

Initialize Class with Generic Types in Another AppDomain

I am trying to setup a tool I can use to load non-version-specific assemblies from a config/database/etc. at runtime, execute code as needed, and then unload them to eliminate overhead. (My situation has many possible alternate code flows, and I'd like to not force a recompile of the entire app to onboard or edit a single flow)

I've setup a library to run AppDomain.CreateInstanceFromAndUnwrap to initialize classes in separate AppDomains, but as far as I can tell, this doesn't support generic type arguments on the class.

How can I initialize classes with type arguments in a different AppDomain than the executing code from a type name and assembly path? If that's not possible, is there any way to load assemblies in a different AppDomain than the executing code such that it handles dependencies automatically the same way that AppDomain.CreateInstanceFromAndUnwrap does (assuming I could then find a way to call Type.MakeGenericType that executes in the temporary AppDomain from the original AppDomain)?





Aucun commentaire:

Enregistrer un commentaire