The LoaderOptimization attribute will never change the fact that statics are allocated on a per-appdomain basis. And not only does it not change the way static variables are stored (see my other reply on this thread), it doesn't cause anyone to go create appdomains for you.
If and only if you (via AppDomain.CreateDomain) or the runtime host you're code is executing in creates multiple appdomains will you see more than one instance of a given type get loaded into the same process. The default process host (used for console apps, non-console [typically winform] apps) just creates one app domain for your code to run in. The ASP.NET host will create multiple app domains to host different web apps or web services in, but that's not the host you're using if you write a process. If you write a service, you're just using the framework classes for a little installation and runtime support (ServiceBase, ServiceInstaller, et. al.) and leveraging the default runtime host. So you only have one appdomain in your process. The service wrappers are not implemented to automatically create separate appdomains in your process just because you have multiple services in your process. They'll all execute in the default appdomain. That's not to say they (or you) couldn't do things differently. But that's not the way the service wrappers are implemented by default - they're just some utility classes; not an entire runtime infrastructure like ASP.NET. -Mike http://staff.develop.com/woodring http://www.develop.com/devresources ----- Original Message ----- From: "Jonni Faiga" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 04, 2002 7:07 AM Subject: Re: [ADVANCED-DOTNET] Singleton pattern Hi, Given an exe that contains multiple services, with LoaderOptimization of SingleDomain, I would presume that each service would be created in separate AppDomain, and they would access to separate Singletons. But this is not the case! You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
