Can you create an initialize method for DLL?

I need to create a service, but the service needs to be in a already existing Class Library file and also the new service needs to start running after the Class Library is installed. Is there a way to create an Init() method or other way to start service inside in Class Library? The project supports max .NET 3.5

Sorry if it sounds dumb, i'm new to the Class Library stuff

Jon Skeet
people
quotationmark

No, class libraries don't support initialization like this.

Note that the library wouldn't even be loaded until it's first used anyway. You could write a type initializer for some appropriate type, and make that start the service - but personally I'd make it explicit if at all possible. (Doing lots of work in type initializers can lead to difficult-to-diagnose issues.)

people

See more on this question at Stackoverflow