How to determine if remoting channel is already registered

≡放荡痞女 提交于 2019-12-04 07:58:05

I've been having this problem too.

The trouble is that you can stop the application that called RemotingConfiguration.Configure() but that doesn't make the channel available. Its something to do with ports or it might just be the name of the channel, I'm not sure.

The solution I found which seems to work is to get the registered channels and unregister the channel you want to remove.

Here is some code

RemotingConfiguration.Configure(appConfig, false);

// do this to unregister the channel
IChannel[] regChannels = ChannelServices.RegisteredChannels;
IChannel channel = (IChannel)ChannelServices.GetChannel(regChannels[0].ChannelName);

ChannelServices.UnregisterChannel(channel);

RemotingConfiguration.Configure(appConfig, false); // this is just a test to see if we get an error

I hope this works for you, it has for me

But what would you do if you found it was already registered?

In any case, I just wanted to make sure you knew that .NET Remoting has been deprecated in favor of WCF.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!