Jay,
I meant IIS when I used the term application server.
So your comment about ASP.Net monitoring the Web.config file sounds like the
behavior I need.
e.g. If I change the Config file then the next call to the class will cause
the constructor to run once.
(I have seen this with regular WebForms so I hope it will work the same
way.)
I will give it a try later.
Thanks.
--
Joe Fallon
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:eM****************@TK2MSFTNGP10.phx.gbl...
Joe,
If you have a Shared Sub New, it will be called once when that class is
first referenced (when the code is loaded basically).
If you create new AppDomains, I understand that it will be called once for
each AppDomain. However I have not done a lot with AppDomains so I can not
say for certain either way.
My question is how would this class behave as a .dll on an application
server? What do you mean by application server?
What would cause it to load and unload?
The only way I can think of is to load & unload the class in new
AppDomains, however I have not done a lot with AppDomains...
But if I change the Config file how do I get it to unload and re-load to
re-read the config file? ASP.NET does this, I believe what it does is to use a
System.FileSystem.Watcher to watch the config file, if the config file
changes it creates a new AppDomain and transfers control to it...
Note, AppDomains also allow you to specify which config file you should
use.
Hope this helps
Jay
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:eq****************@TK2MSFTNGP12.phx.gbl... I have a Shared class with a New constructor that initializes some
Shared properties.
One of the steps involves a hit to the database.
My tests show that when called by a WinForms app, the constructor only
runs once.
All calls to the class after this do not casues the construtor to run
again. This means it is a one time hit to the database to load these
properties. 1. Can someone confirm this?
When I start and stop the WinForms app the Shared class needs to be
initialized on each re-start.
This makes sense.
My question is how would this class behave as a .dll on an application
server?
What would cause it to load and unload?
I guess the load would be caused by the first call from another class.
But if I change the Config file how do I get it to unload and re-load to
re-read the config file?
--
Joe Fallon