C# IPC: Access Denied in Windows Vista

Microsoft introduced a new form of Remoting in .NET 2.0 under System.Runtime.Remoting.Channels.Ipc, which used named pipes for remoting instead of HTTP or TCP connections. The named pipes are supposed to be much faster to use (which seems to be true) and work extremely well on a local machine. And, they work flawlessly by default in Windows XP. Of course, the remoting setup is practically the same as other remoting methods (refer to a remoting tutorial for more information on how remoting works).

However, in Windows Vista, they changed around the way named pipes work, and they haven’t clearly documented it in their documentation. Windows Vista has a stricter ACL created by default for named pipes. Heres the code that lets your service communicate with your code running in userspace:

IpcServerChannel channel;

IDictionary properties = new Hashtable();
properties.Add("authorizedGroup", "Users");
properties.Add("portName", "NCChannel");
properties.Add("rejectRemoteRequests", true);

// create the channel and start it up
channel = new IpcServerChannel(properties,null);

Pretty simple, eh? They should probably mention it a little bit more explicitly in their docs..

Leave a Reply