如何确定远程通道是否已注册

发布于 2024-07-27 22:08:26 字数 267 浏览 3 评论 0原文

在我的 ASP.NET 应用程序中,全局应用程序启动事件中有一行通过调用 RemotingConfiguration.Configure() 来配置客户端远程处理通道。

这第一次运行良好,但是当我的 Web 应用程序被回收时,应用程序启动事件再次被触发,导致以下远程异常:

远程配置失败,出现异常“System.Runtime.Remoting.RemotingException:通道“tcp”已经存在挂号的。

我想检测通道是否已配置,以便我可以避免出现此异常。

In my ASP.NET application, I have a line in the global application start event that configures the client remoting channel by calling RemotingConfiguration.Configure().

This works well the first time, but when my web application gets recycled, the application start event is fired again causing the following remoting exception:

Remoting configuration failed with the exception 'System.Runtime.Remoting.RemotingException: The channel 'tcp' is already registered.

I would like to detect if the channel is already configured so that I can avoid getting this exception.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

转瞬即逝 2024-08-03 22:08:26

我也一直遇到这个问题。

问题是您可以停止调用 RemotingConfiguration.Configure() 的应用程序,但这不会使通道可用。 我不确定它与端口有关,或者可能只是通道的名称。

我发现似乎有效的解决方案是获取已注册的频道并取消注册要删除的频道。

这是一些代码,

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'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

谁与争疯 2024-08-03 22:08:26

但如果你发现它已经被注册了,你会怎么做?

无论如何,我只是想确保您知道 .NET Remoting 已被弃用,取而代之的是 WCF。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文