Hi Listies,
I'm trying to use the FileStream class to read from an Asynchronous pipe
that
was created on the unmanaged side of an application.
I've created a unmannaged C++ console app that hosts the CLR. Before
initializing
The CLR, the program create a named pipe with the OVERLAPPED flag like this:
Pipe = ::CreateNamedPipe( L"\\\\.\\pipe\\dispatcher",
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_READMODE_BYTE,
PIPE_UNLIMITED_INSTANCES, 4096, 4096,
NMPWAIT_USE_DEFAULT_WAIT,
NULL );
After CLR is initialized, I instanciate a managed class in the default
domain
using _AppDomain.CreateInstance. I call a method on this class that takes
the pipe handle as a
parameter 'Run( int Pipe )'
On the managed side, I convert the int into an IntPtr and create a
FileStream class like this:
IntPtr PipePtr = new IntPtr(Pipe);
FileStream fs = new FileStream(PipePtr, FileAccess.ReadWrite, false, 4096,
true );
The problem is that the FileStream constructor allways throws an exception:
Void .ctor(IntPtr, System.IO.FileAccess, Boolean, Int32, Boolean)
System.ArgumentException mscorlib: Handle does not support asynchronous
operations. The parameters to the FileStream constructor may need to be
changed to indicate that the handle was opened synchronously (that is, it
was not opened for overlapped I/O).
The Pipe surely HAS been open for asynchronous mode!?
Does anyone know what's going on?
Fr�d�ric Gos
Senior Software Architect
Composite Netsystems
Phone: +45 35 55 23 52
Mobile: +45 20 91 67 71
-----------------------------------------------------------------------
Learn more about Composite on www.composite.net