Question

I want to Dispose of some objects that are created during a WCF service method, but I need to clean them up outside of the scope of the method that created them. When I'm working in ASP.NET, I normally call that code during the Application_EndRequest event.

If the answer is: there is no Application_EndRequest-like event in WCF, how should I go about cleaning up my objects?

Was it helpful?

Solution

You can implement IDisposable for your WCF service. If the service is configured PerSession or PerCall *context mode* dispose method will be called once the channel is closed and the service instance is dropped.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top