Is there an equivalent of Application_Start for a class library in c#
问题 I would like to execute certain code in a class library when it is instantiated from another assembly. Is there an entry point or bootstrap for a class library? I thought that a static method Main would do the trick but I was wrong. Applications for this might be configuring and instantiating a logger singleton, unhandled exception handler, etc. 回答1: AppDomain.AssemblyLoad Event which occurs when an assembly is loaded. Probably that can be used to call an initialize method in your class