mardi 27 juin 2017

DllMain equivalent in C#

I have a managed C# application that loads managed plugins. Depending on a condition I want to be able to run some code on assembly load that will monkey patch the host application to hook some methods.

I tried using module initializers but the .cctor is not called until it tries to reference something in the DLL.

I have seen the answers for C# equivalent of DllMain in C (WinAPI) but none works for me

(this DLL must be a managed DLL; this answer C# equivalent of DllMain in C (WinAPI) won't work as the host application expects to find some managed classes based on an attribute and what I'll have is a native dll.)

Please note that I can not modify the host application.





Aucun commentaire:

Enregistrer un commentaire