[Mono-devel-list] async IO & Exceptions on NetworkStream: Windows vs. Mono

Brad Fitzpatrick brad at danga.com
Thu Dec 25 21:47:42 EST 2003


Hello!

I've found a behavioral difference between .NET on Windows and Mono.

According to the docs I've read on .NET's async design patterns,
exceptions thrown in worker threads from async method calls should be
re-thrown when the caller thread executes EndInvoke(IAsyncResult) (or
EndWrite/EndRead/etc).

With mono, it's impossible to catch these errors, at least for the case of
NetworkStream.BeginWrite(..).  If the client reading from the
NetworkStream disconnects, a SocketException is thrown, and the backtrace
mono dumps shows it ending in the worker thread.  But I can't catch it:
not around ns.BeginWrite() nor ns.EndWrite().

On Windows, however, the exception is thrown from ns.EndWrite() so I can
do the proper cleanup.  (this seems to be the correct behavior)

I can't even determine if this is a runtime or code generation issue
because the binary I built with csc on Windows won't run under mono.  Just
says:  "cannot open assembly filename.exe"

(I've actually been learning and developing C# with Mono.  Today was the
 first time I've used .NET on Windows.)

Is this a known bug, or should I submit a test case?

Thanks!

-- 
Brad Fitzpatrick
http://www.danga.com/
brad at danga.com



More information about the Mono-devel-list mailing list