views:

179

answers:

2

I have something I want to initialise and use throughout a WCF Service Library. If it was in an ASP.NET site I'd be doing it in the Application_Start method of the global.asax, but what's the equivalent for a WCF Service Library?

+2  A: 

I use a static singleton that I lazy-initialize where I hold all of the app state, and I feel gross every time I do it.

Paul Betts
Yes, that's what I'm doing at the moment. Is there's anything really wrong with that though?
A: 

You can make sessionful WCF components.

Please see my response over on this question: Sessionful wcf service in Silverlight

You can even make durable sessionful objects that retain their state after you've disconnected from them (saving it to a file or sql server). Chapter 4 of Juval Lowy's book goes into some detail of that as well.

Is that kind of what you're looking for?

Terry Donaghe
Thanks, but no, not quite. I need to set up a global at the application level rather than the session.
Sessions also make WCF suck to test unless you do work to abstract them away
Paul Betts