在.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);
}
}