views:

317

answers:

1

My web app exposes a few services (WCF) and I need to load an XML file and 'store' it a static variable visible to the entire AppDomain. That variable needs to be queried and updated from either a service or a page.

The thing is, I load that variable in the Application_Start (Global.asax.cs) but when a service request arrives the variable is empty and needs to be 'reloaded', and that happens with every service (3), so I end up with 3 instances of a static variable.

How can I ensure that all my applications are running on the same AppDomain? what am I doing wrong?

VS2008 SP1 on Win7 RTM box

+3  A: 

Ok, so after a bit of research I found the solution. I'll posting the solution here and many links that helped me find it.

WCF services and ASPX pages DO run on the same AppDomain when running side-by-side (default), my problem was that the AppDomain was being recycled because my app was creating a folder below the root folder of my app. When I moved that creation away from the app itself, the AppDomain quited restarting so I always keep my static values.

Here's a list of interesting post I read and helped my find the solution:

sebastian
thanks John ...
sebastian
great post link
Mike108