连接到 .NET 远程服务器对象的最简单方法是什么
鉴于我的客户端代码了解远程对象所需的一切,那么连接到它的最简单方法是什么?
这就是我现在正在做的事情:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
前两行位于服务器端代码中,用于封送服务器对象,是吗?
在这种情况下,是的,第三行是您可以在客户端获得的最简单的行。
此外,如果您在IRemoteServer接口中包含它们的公共访问器,您可以从MyServerObject实例提供其他服务器端对象,因此,访问这些对象变得简单主要服务器对象上的方法调用或属性访问问题,因此您不必对每件事都使用激活器:
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:
世界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.