注册众所周知的客户端类型时出现异常

发布于 2024-08-06 19:19:59 字数 717 浏览 1 评论 0原文

我正在使用 .NET 远程处理在客户端和服务器之间进行通信。我实现了客户端应用程序,并在使用“RegisterWellKnownClientType”在客户端上注册对象时遇到了异常。例外情况是“尝试重定向已重定向的类型的激活”。仅当我第二次注册该对象时才会出现此异常。下面是说明它的代码:

IpcClientChannel clientChannel = new IpcClientChannel();
try
   {
      ChannelServices.RegisterChannel(clientChannel, true);
      RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), m_remoteUrl);             
   }    

此代码在我的 ClientClass 中实现。最初,我创建一个对象,例如 ClientClassmyClient 来访问此类公开的方法。这还包括在客户端注册对象的方法。一旦这个对象(myClient)被处理,我就创建另一个ClientClass实例并访问在客户端注册该对象的方法。在此过程中,我遇到了上述异常。使用在客户端注册对象的方法来对服务器进行远程调用。

如果我在这里遗漏了什么,请告诉我。

谢谢, 穆斯塔克

I am using .NET remoting to communicate between the client and server. I implemented the client application and encountered an exception while registering an object on the client using "RegisterWellKnownClientType". The exception is "attempt to redirect activation of type which is already redirected". I get this exception only when I register the object for the second time. Here is the code that illustrates it:

IpcClientChannel clientChannel = new IpcClientChannel();
try
   {
      ChannelServices.RegisterChannel(clientChannel, true);
      RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), m_remoteUrl);             
   }    

This code is implemented in my ClientClass. Initially i create an object say myClient of ClientClass to access the methods exposed by this class. This also includes the method to register the object on the client. Once this object (myClient) is disposed i create another instance of the ClientClass and access the method which registers the object on the client. During this process i get the above mentioned exception. The method to register the object on the client is used in order to make remote calls to the server.

Let me know if I am missing anything here.

Thanks,
Mustaq

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

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

发布评论

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

评论(2

电影里的梦 2024-08-13 19:19:59

测试您是否已经注册了客户端类型,如下所示:

if (RemotingConfiguration.IsWellKnownClientType(typeof(RemoteTester)) == false) {
    // register
    RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), ...
}

-Oisin

Test if you have already registered the client type like so:

if (RemotingConfiguration.IsWellKnownClientType(typeof(RemoteTester)) == false) {
    // register
    RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), ...
}

-Oisin

情话墙 2024-08-13 19:19:59

IsWellKnownClientType(..,..) 此方法不返回 bool 值,

如果检查指定对象 System.Type 是否注册为众所周知的客户端类型, 则返回 WellKnownClientTypeEntry。如果 WellKnownClientTypeEntry 为 null,则不注册。

这是我解决问题的代码。希望它能帮助您...

WellKnownClientTypeEntry 条目 = RemotingConfiguration.IsWellKnownClientType(typeof(RemoteConverter));

如果(条目==空)
{
RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteConverter), "http://localhost:4000/ServiceURI");
}

RemoteConverter RemoteConverter = new RemoteConverter();

现在调用远程方法remoteConverter.RemoteMethod(.......)


谢谢。

IsWellKnownClientType(..,..) this methos is not returning bool value, it returns WellKnownClientTypeEntry

if checks whether the specified object System.Type is registered as a well-known client type. if WellKnownClientTypeEntry is null then not register.

Here is my code to solve the problem. hope it wiil help you...

WellKnownClientTypeEntry entry = RemotingConfiguration.IsWellKnownClientType(typeof(RemoteConverter));

if (entry == null)
{
RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteConverter), "http://localhost:4000/ServiceURI");
}

RemoteConverter remoteConverter = new RemoteConverter();

now call the remorte Methods remoteConverter.RemoteMethod(.......)


thank you.

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