Inner exception is of type SystemObjectDisposedException with message : "Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'"
This happens when I dispose the ImapClient object in my class destructor like so:
It seems to be some kind of race condition given that some times it succeeds and others(especially when I have a break point on it for a couple of seconds) it fails.
Full stack trace from outer exception:
at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at AE.Net.Mail.TextClient.SendCommand(String command)
at AE.Net.Mail.ImapClient.OnLogout()
at AE.Net.Mail.TextClient.Logout()
at AE.Net.Mail.TextClient.Disconnect()
at AE.Net.Mail.TextClient.Dispose(Boolean disposing)
at AE.Net.Mail.TextClient.Dispose()
Stack trace from inner exception:
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
Inner exception is of type SystemObjectDisposedException with message : "Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'"
This happens when I dispose the ImapClient object in my class destructor like so:
~EmailAddress() { if(_client != null && !_client.IsDisposed) _client.Dispose(); }
It seems to be some kind of race condition given that some times it succeeds and others(especially when I have a break point on it for a couple of seconds) it fails.
Full stack trace from outer exception: at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count) at AE.Net.Mail.TextClient.SendCommand(String command) at AE.Net.Mail.ImapClient.OnLogout() at AE.Net.Mail.TextClient.Logout() at AE.Net.Mail.TextClient.Disconnect() at AE.Net.Mail.TextClient.Dispose(Boolean disposing) at AE.Net.Mail.TextClient.Dispose()
Stack trace from inner exception: at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)