两种类型都是服务器激活的对象
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application name="SimpleServer">
<service>
<wellknown mode="SingleCall" type="SimRemote1.RemoteObject,SimRemote1" objectUri="RemoteObject">
</service>
<channels>
<channel ref="tcp server" port="8080"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
客户端配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration><system.runtime.remoting>
<application name="SimpleClient">
<client url> //原来是这个<client url="tcp://localhost:8080/SimpleServer">
//<activated type="SimRemote1.RemoteObject,SimRemote1"/>
<wellknown type="SimRemote1.RemoteObject,SimRemote1" url="tcp://localhost:8080/SimpleServer/RemoteObject" />
</client>
<channels>
<channel ref="tcp client" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
单独调用对象在开始调用时被创建,调用结束的时候被释放。确保宝贵的内存不会被长时间占有。客户端可以随时保留对对象代理的引用,代理根据每个调用来创建远程对象。
单独调用对象是不具有状态。
例如,创建一个服务器对象从数据库中读取大量的数据并且为客户端提供聚合信息(可能客户端使用慢速internet连接,而且原始数据又非常大。),这种情况下,需要一个客户端对象或单独对象来得到数据,否则每次方法调用远程对象都要重新查询数据库。
单独对象
单独对象和客户端激活对象一样,时具有状态的。只是它是有服务器创建。
mode="Singleton"
单独对象的客户端配置和单独调用对象的配置是一样的。