Can you detect when your assembly is loaded?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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?
 
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.
 
Back
Top