I have WCF
service that is hosted in IIS
.
I need to initialize once several things that will exists through all calls to the services.
Where is the appropriate place to make those initializations ?
Thanks for assistance .
I have WCF
service that is hosted in IIS
.
I need to initialize once several things that will exists through all calls to the services.
Where is the appropriate place to make those initializations ?
Thanks for assistance .
Use constructor (either that of BaseService or actual service class) to initialize these properties
Bear in mind that when WCF service is configured for Per-Call instance mode, Service instance will be created for each client request
If is not strictly needed don't use any Singleton strategy:
Singleton WCF services should hardly ever be used- Singletons are the enemy of scalability! They only make sense in weird scenarios- logging to a single file, a single communications port or hardware device.
You can initialize them in static constructor or using Container's with Lifetime manager.
If your WCF service is configured to use ASP.NET Compatibility Mode, then just initialize them in Application_OnStart in Global.asax.