Hooking into an “OnLoad” for class library

后端 未结 3 1263
深忆病人
深忆病人 2020-12-18 10:48

Does anyone know if there\'s a way to hook into an \"OnLoad\" event to run some operations when an assembly loads?

Specifically, I am creating a plug-in for an appli

3条回答
  •  醉话见心
    2020-12-18 11:31

    C# does not provide a way to do that but the underlying IL code does via module initializers. You can use tools like Fody/ModuleInit to turn a specially named static C# class to run as a module initializer which will be run when your dll is loaded.

提交回复
热议问题