mercredi 21 août 2019

c# reflection: load assembly and replace class

I'd like to dynamically load a c# dll into my program and replace a class in the loaded dll. Is this possible?

The loading of the dll and the instantiating of the class (from the dll) are at two different locations and I don't want to change the instantiating class.

My first idea was to handle the AppDomain.TypeResolve event. But it's never triggered. If I don't load the dll in AppDomain.AssemblyResolve I get an exception. If I do so AppDomain.TypeResolve is not triggered.

As I already said I don't want to change the code that is using the dll. I want to inject another class without the caller noticing (in the best case)





Aucun commentaire:

Enregistrer un commentaire