C
Chris Hudson
Any help you can offer on this would be most welcome. Its making me pull
out what little hair I have left!
A strange exception is raised occasionally by the following code:
byte[] buffer = new ASCIIEncoding().GetBytes(toSend);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new
Uri(serviceUri));
httpWebRequest.ContentLength = toSend.Length;
httpWebRequest.ContentType = postType;
httpWebRequest.Method = "POST";
Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Close();
StreamReader responseStream = new
StreamReader(httpWebRequest.GetResponse().GetResponseStream());
string received = responseStream.ReadToEnd();
responseStream.Close();
It only seems to happen the first time after the code has been rebuilt, or
has not been called for some time (a number of hours). If the code is
regularly called, then the exception is not raised.
The code is in a C# WebService. I am using .NET Framework 1.1 on a Windows
XP (SP2) machine.
The exception message is:
Exception:-
System.ObjectDisposedException: Cannot access a disposed object named
"System.Net.TlsStream".
Object name: "System.Net.TlsStream".
at System.Net.TlsStream.InnerWrite(Boolean async, Byte[] buffer, Int32
offset, Int32 size, AsyncCallback asyncCallback, Object asyncState)
at System.Net.TlsStream.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Connection.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32
size)
out what little hair I have left!
A strange exception is raised occasionally by the following code:
byte[] buffer = new ASCIIEncoding().GetBytes(toSend);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new
Uri(serviceUri));
httpWebRequest.ContentLength = toSend.Length;
httpWebRequest.ContentType = postType;
httpWebRequest.Method = "POST";
Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Close();
StreamReader responseStream = new
StreamReader(httpWebRequest.GetResponse().GetResponseStream());
string received = responseStream.ReadToEnd();
responseStream.Close();
It only seems to happen the first time after the code has been rebuilt, or
has not been called for some time (a number of hours). If the code is
regularly called, then the exception is not raised.
The code is in a C# WebService. I am using .NET Framework 1.1 on a Windows
XP (SP2) machine.
The exception message is:
Exception:-
System.ObjectDisposedException: Cannot access a disposed object named
"System.Net.TlsStream".
Object name: "System.Net.TlsStream".
at System.Net.TlsStream.InnerWrite(Boolean async, Byte[] buffer, Int32
offset, Int32 size, AsyncCallback asyncCallback, Object asyncState)
at System.Net.TlsStream.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Connection.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.BeginWrite(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32
size)