Is there a way for class library to detect when it’s loaded, in order to perform some initialization?
I’ve tried adding Program.cs with static Main method, which didn’t help. I tried setting Startup object in project properties, but only (None) is available.
I know Win32 libraries have entry points, do .NET class libraries have them?
You can’t do it directly in C# or VB.NET, but the CLR itself supports Module Initializers, which I think is what you’re asking for. You’d normally need to use ilasm in order to pull it off.
It looks like somebody also figured out a way to do it in C# using Mono.Cecil. It’s still pretty complicated. You’re better off using a static constructor if you know that some specific type will be referenced as soon as the assembly is loaded. Otherwise – good luck.