wcf possible to override the dipose of proxy
- by pdiddy
I'd like to override the Dispose method of generated proxy (ClientBase) because of the fact that disposing of a proxy calls Close and can throw an exception when the channel is faulted.
The only way I came up was to create a partial class to my generatedproxy, make it inherit from IDisposable. :
public partial class MyServiceProxy : IDisposable
{
#region IDisposable Members
public void Dispose()
{
if (State != System.ServiceModel.CommunicationState.Faulted)
Close();
else
Abort();
}
#endregion
}
I did some test and my Dipose method is indeed called.
Do you see any issue with this strategy?
Also, I don't like the fact that I'll have to create this partial class for every generated proxy.
It be nice if I was able to make my proxy inherit from a base class...