Error using TCPClient w/ 3.5 CF and Windows Mobile


B

Bob Trabucco

Hello all.

I have a application written in the 3.5 Compact Framework running on Windows
Mobile devices. VB.NET VS 2008.

The application communicates with our server using the
System.Net.Sockets.TcpClient class

This code used to communicate works flawlessly in our regular windows
application. It also works wonderfully when the device (Treo 700 is my test
case) is plugged into a PC with the USB cable. When not plugged in and
using the internet over the cell phone it will occasionally crash with:

ObjectDisposedException
at System.Threading.Timer.throwIfDisposed()
at System.Threading.Timer.Change(UInt32 dueTime, UInt32 period)
at System.Threading.Timer.Change(Int32 dueTime, Int32 period)
at System.Net.HttpWebRequest.startReadWriteTimer()
at System.Net.HttpWebRequest.ConnectionClient.Read(Byte[] data, Int32
offset, Int32 length)
at System.Net.HttpReadStream.NetworkRead(Byte[] data, Int32 offset, Int32
length)
at System.Net.ChunkedReadStream.fillBuffer()
at System.Net.ChunkedReadStream.getLine()
at System.Net.ChunkedReadStream.doRead(Byte[] data, Int32 offset, Int32
length)
at System.Net.HttpReadStream.ReadToDrain(Byte[] buffer, Int32 offset,
Int32 length)
at System.Net.HttpReadStream.doClose()
at System.Net.HttpReadStream.Finalize()

It may work great a few times - then crash like this. This error appears
untrappable - all my code is Try/Catched. We don't believe this was a issue
in previous versions of the framework but this is our first release using
2008/3.5 so it's hard to say for sure.

Anyone out there have a clue as to what may be causing this and what steps I
can take to trap the error and/or prevent it?

Thanks so much in advance.

Bob
 
Ad

Advertisements

M

miguel.madero

We have the same problem with the HttpReadStream class, here's our
StackTrace:

en System.Threading.Timer.throwIfDisposed()
en System.Threading.Timer.Change(UInt32 dueTime, UInt32 period)
en System.Threading.Timer.Change(Int32 dueTime, Int32 period)
en System.Net.HttpWebRequest.ConnectionClient.Read(Byte[] data, Int32
offset, Int32 length)
en System.Net.HttpReadStream.NetworkRead(Byte[] data, Int32 offset,
Int32 length)
en System.Net.ChunkedReadStream.fillBuffer()
en System.Net.ChunkedReadStream.getLine()
en System.Net.ChunkedReadStream.doRead(Byte[] data, Int32 offset,
Int32 length)
en System.Net.HttpReadStream.ReadToDrain(Byte[] buffer, Int32 offset,
Int32 length)
en System.Net.HttpReadStream.doClose()
en System.Net.HttpReadStream.Finalize()

In our case we're aborting the thread doing the request, I think that
might be the problem a we might need to handle a ThreadAbortException
and aborting the operation there.
I will let you know if this solves anything.
 
B

Bob Trabucco

Thanks for letting me know if you find anything.

My example is not threaded but who knows it's doing a few layers down.
 
A

Abhinav gujjar

This can occur if GetResponse from an webrequest is not handled correctly.

Ensure that after calling GetResponse, you are indeed relialy calling a close on the response object. Otherwise a stream would be opened up under the covers with a default timeout of 5 mins, and this would wake up and find the request to be disposed already and hence the objectdisposed exception.

This is one of the causes and and good check to perform
 
Ad

Advertisements

B

Bob Trabucco

THANK YOU!!!

That absolutely was the problem. Everything works wonderfully now. I won't
make that mistake again...
 

Top