Can you detect when your assembly is loaded?

G

Guest

I'm writing a class library that will be consumed by other applications,
both web and form, and may also be loaded dynamically. I need the assembly to
perform some validation immediately after it is loaded, and possibly shut
itself down. I cannot find an event or mechanism to detect when my assembly
is loaded. Any suggestions?
 
J

Jamin Guy

Could you use a factory pattern to create all the instances of your
objects and then add the validation code to the factory class so that
the first time an object instantiation is attempted the factory class
could check for validation and then set a boolean to allow or prevent
that and future instantiations?
 
D

David Levine

You can use a static class constructor. The first time your class is used
the static ctor will be invoked before any of the instance methods or fields
can be accessed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top