[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Trouble with named pipe, getting "could not open pipe message"

tpknomad

6/22/2007 2:24:00 PM

I have a service running as local system, and a GUI that resides in a user
account. When I try to open a named pipe to connect to the service, I get a
"could not open pipe" message. Now I know that the pipe has no security set,
so it must be getting blocked in Vista on that basis. Here is a small sample
of the c# code that creates the pipe, where and how do I enable connections
for everyone. I don't want any security on this pipe.

public PipeHandle(PipeURI URI,PipeHandleType type, int inBufferSize, int
outBufferSize)
{
_URI = URI;
_Type = type;
_BufferIn = inBufferSize;
_BufferOut = outBufferSize;
}
public PipeHandle(string pipeURI,PipeHandleType type, int inBufferSize, int
outBufferSize)
{
_URI = new PipeURI(pipeURI);
_Type = type;
_BufferIn = inBufferSize;
_BufferOut = outBufferSize;
}
internal void CreateHandle() {
switch (_Type) {
case PipeHandleType.Server:
_Handle =
UnsafeNativeMethods.CreateNamedPipe(_URI.FullName,

(int)FileAccess.ReadWrite|UnsafeNativeMethods.FILE_FLAG_OVERLAPPED,

UnsafeNativeMethods.PIPE_TYPE_BYTE | UnsafeNativeMethods.PIPE_WAIT,

UnsafeNativeMethods.PIPE_UNLIMITED_INSTANCES,
_BufferIn,
_BufferOut,

UnsafeNativeMethods.NMPWAIT_WAIT_FOREVER,
IntPtr.Zero);
break;
case PipeHandleType.Client:
_Handle = UnsafeNativeMethods.CreateFile(_URI.FullName,

(int)FileAccess.ReadWrite,

(int)System.IO.FileShare.ReadWrite,
IntPtr.Zero,
(int)System.IO.FileMode.Open,

UnsafeNativeMethods.FILE_FLAG_OVERLAPPED,
IntPtr.Zero);
break;
}
if (_Handle.IsInvalid) throw new IOException("Could not open
pipe.");
}

Any ideas? A code sample would be sweeeet.