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);
}
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);
}