HighTechTalks DotNet Forums  

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

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Trouble with named pipe, getting "could not open pipe message" in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?dHBrbm9tYWQ=?=
 
Posts: n/a

Default Trouble with named pipe, getting "could not open pipe message" - 06-22-2007 , 10:24 AM






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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.