Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error using TCPClient w/ 3.5 CF and Windows Mobile

284 views
Skip to first unread message

Bob Trabucco

unread,
Jul 16, 2008, 9:34:59 AM7/16/08
to
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


miguel...@gmail.com

unread,
Jul 17, 2008, 3:35:24 AM7/17/08
to
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.

Bob Trabucco

unread,
Jul 17, 2008, 8:46:57 AM7/17/08
to
Thanks for letting me know if you find anything.

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


<miguel...@gmail.com> wrote in message
news:fbd9c66a-2085-4e04...@k37g2000hsf.googlegroups.com...

abhinavgujjar

unread,
Jul 20, 2008, 2:17:15 PM7/20/08
to
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

Bob Trabucco

unread,
Jul 21, 2008, 9:23:18 AM7/21/08
to
THANK YOU!!!

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

<Abhinav gujjar> wrote in message
news:2008720141715...@gmail.com...

0 new messages