连接到 .NET 远程服务器对象的最简单方法是什么

发布于 2024-07-04 12:30:39 字数 434 浏览 4 评论 0原文

鉴于我的客户端代码了解远程对象所需的一切,那么连接到它的最简单方法是什么?

这就是我现在正在做的事情:

ChannelServices.RegisterChannel(new HttpChannel(), false);

RemotingConfiguration.RegisterWellKnownServiceType(
    typeof(IRemoteServer), "RemoteServer.rem", WellKnownObjectMode.Singleton);

MyServerObject = (IRemoteServer)Activator.GetObject(
    typeof(IRemoteServer),
    String.Format("tcp://{0}:{1}/RemoteServer.rem", server, port));

Given that my client code knows everything it needs to about the remoting object, what's the simplest way to connect to it?

This is what I'm doing at the moment:

ChannelServices.RegisterChannel(new HttpChannel(), false);

RemotingConfiguration.RegisterWellKnownServiceType(
    typeof(IRemoteServer), "RemoteServer.rem", WellKnownObjectMode.Singleton);

MyServerObject = (IRemoteServer)Activator.GetObject(
    typeof(IRemoteServer),
    String.Format("tcp://{0}:{1}/RemoteServer.rem", server, port));

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

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

发布评论

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

评论(2

爱冒险 2024-07-11 12:30:39

前两行位于服务器端代码中,用于封送服务器对象,是吗?

在这种情况下,是的,第三行是您可以在客户端获得的最简单的行。

此外,如果您在IRemoteServer接口中包含它们的公共访问器,您可以从MyServerObject实例提供其他服务器端对象,因此,访问这些对象变得简单主要服务器对象上的方法调用或属性访问问题,因此您不必对每件事都使用激活器:

//obtain another marshalbyref object of the type ISessionManager:
ISessionManager = MyServerObject.GetSessionManager();

The first two lines are in the server-side code, for marshaling out the server object, yes?

In that case, yes, the third line is the simplest you can get at client-side.

In addition, you can serve out additional server-side objects from the MyServerObject instance, if you include public accessors for them in IRemoteServer interface, so, accessing those objects become the simple matter of method calls or property accesses on your main server object, so you don't have to use activator for every single thing:

//obtain another marshalbyref object of the type ISessionManager:
ISessionManager = MyServerObject.GetSessionManager();
童话 2024-07-11 12:30:39

世界CF。

在WCF出现之前我就用过IPC,相信我,IPC是个熊。 并且它没有完整/正确地记录。

连接到 .NET 远程服务器对象的最简单方法是什么? 世界CF。

WCF.

I have used IPC before there was a WCF, and believe me, IPC is a bear. And it isn't documented fully/correctly.

What’s the simplest way to connect to a .NET remote server object? WCF.

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