I don't know if its help you but ...

I managed to create DLL (managed\unmanaged C++) that utilized mailslots and
memory map files. In both cases I do all the work against the IPC only with
unmanaged code. The managed class serves as a gateway between the client
(managed code) and unmanaged code. (In one case the DLL build from ATL
class, managed class and unmanaged class so the DLL can be called from COM
and CLR) anyway while working this way I haven't experience any problems as
you mention.

----- Original Message -----
From: "Frederic Gos" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 20, 2003 6:06 PM
Subject: [ADVANCED-DOTNET] FileStream on Asynchronous named pipe


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

Reply via email to