471,338 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Can you detect when your assembly is loaded?


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?
Jul 22 '05 #1
2 1747
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?

Jul 22 '05 #2
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.

"Jeff Lar" <Je*****@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com...

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?

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Outshined | last post: by
1 post views Thread by Zachary Hartnett | last post: by
reply views Thread by Chee | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.