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?
views:
179answers:
2
+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
2010-01-15 03:06:50
Yes, that's what I'm doing at the moment. Is there's anything really wrong with that though?
2010-01-15 03:09:50
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
2010-01-15 03:09:41
Thanks, but no, not quite. I need to set up a global at the application level rather than the session.
2010-01-15 03:19:58
Sessions also make WCF suck to test unless you do work to abstract them away
Paul Betts
2010-01-15 05:45:01