在.NET框架中,可以通过以下几种方法配置C# Remoting:
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="Singleton" type="MyNamespace.MyRemoteObject, MyAssembly" objectUri="MyRemoteObject.rem" />
</service>
<channels>
<channel ref="tcp" port="1234" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyNamespace.MyRemoteObject), "MyRemoteObject.rem", WellKnownObjectMode.Singleton);
TcpChannel channel = new TcpChannel(1234);
ChannelServices.RegisterChannel(channel, false);
public class MyRemoteObject : MarshalByRefObject
{
public MyRemoteObject()
{
TcpChannel channel = new TcpChannel(1234);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoteObject), "MyRemoteObject.rem", WellKnownObjectMode.Singleton);
}
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:c#指令 能否进行远程调用