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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top