Cannot access a disposed object

Jesus Ramos picture Jesus Ramos · Aug 4, 2010 · Viewed 14.2k times · Source

I am writing a tool to integrate with a web service, I have a method which just builds an ImportExportSoapClient object which is used to call the API methods for the web service, but when I call one of the methods I am getting Cannot access a disposed object System.ServiceModel.Channels.ServiceChannel? anyone had a similar experience or could lend a hand?

Answer

Jay picture Jay · Aug 4, 2010

You may be trying to use an already-closed CommunicationObject (like a ChannelFactory). When the object is in a Closed or Closing state, you get an ObjectDisposedException.

MSDN Reference: http://msdn.microsoft.com/en-us/library/ms405496.aspx