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?
 
Depends on how you interpret "loaded".
If some pgm reads assembly as binary file and does something with its
content - is it loaded or just read? See reflector or anakrino. There
couldn't be any in-assembly event except in-OS, like windows hook which
intercepts file reads. Of course, if you are thinking Windows.

Otherwise, as soon as code starts to run in your assembly it is "loaded and
executed"

HTH
Alex
 
after reading the previous peace of useless advice I though it was time to
right the wrong ;-)

AppDomain.CurrentDomain.AssemblyLoad += new
AssemblyLoadEventHandler(myHandler);


sometimes a quick look in the documentation it's all it takes!
 
Back
Top