Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IPC error

Status
Not open for further replies.

haddaway

Programmer
Jul 6, 2005
172
SE
I have created some IPC channels which I use successfully. But sometimes, when registering a channel at startup I get this error message:

System.Runtime.Remoting.RemotingException: Failed to create an IPC Port: Access is denied.

at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.StartListening(Object data)
at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.SetupChannel()
at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, CommonSecurityDescriptor securityDescriptor)
at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider)

The error appears on this line:

LocalChannel = new IpcServerChannel(properties, null);

This happens often when I try to start one of the application in a short time after shutting it down. Even though I have these lines:

LocalChannel.StopListening(null);
ChannelServices.UnregisterChannel(LocalChannel);
ChannelServices.UnregisterChannel(RemoteChannel);

Here is the full code for registring the channels:

public void RegisterRemoteApp()
{
RemoteChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(RemoteChannel,false);
RemoteApp = (MessageHandler)Activator.GetObject(typeof(MessageHandler), "ipc://" + LocalAppName + "/" + MHandler);
}

public void RegisterLocalApp()
{
IDictionary properties = new Hashtable();
properties["name"] = RemoteAppName;
properties["portName"] = RemoteAppName;
properties["authorizedGroup"] = "Everyone";

LocalChannel = new IpcServerChannel(properties, null);

ChannelServices.RegisterChannel(LocalChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MessageHandler), MHandler, WellKnownObjectMode.SingleCall);
// start listener delegate
MessageHandler.EventEnvelope += new MessageHandler.DelegateEnvelope(MessageHandler_EventEnvelope);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top