S h o r t S t o r i e s

// Tales from software development

Failed to create an IPC Port: Access is denied.

leave a comment »

I’ve just wasted half an hour overlooking something very basic regarding the .NET IpcChannel.

The only excuse I have is that I was reworking some .NET Remoting code that used HttpChannels. I kept getting the “Failed to create an IPC Port: Access is denied.” error whenever I started the client application. Both the server and client code created the properties for the IpcChannel with this code:

Hashtable properties = new System.Collections.Hashtable();
properties.Add("portName", Constants.IpcPortName);

 
I’d overlooked the fact that IPC channels must be uniquely named. I changed the name of the constant from IpcPortName to IpcServerPortName and added another named IpcClientPortName. Obviously, the values of the two constants are different.

I updated the client code to use a different name and, while I was at it, to use a name based on the process id so that multiple clients would always have unique names as well:

Hashtable properties = new System.Collections.Hashtable();
properties.Add("portName", Constants.IpcClientPortName + 
    Process.GetCurrentProcess().Id.ToString());

 

Advertisements

Written by Sea Monkey

March 9, 2010 at 9:00 pm

Posted in Development

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: