.Net Remoting配置文件的用法
来源:互联网 发布:数据透视表行总计求和 编辑:程序博客网 时间:2024/05/21 12:39
How to use .Net Remoting Configuration files
.NET Remoting configuration files allow you to specify parameters for most aspects of the remoting framework. These files can define tasks as simple as registering a channel and specifying a Type as a server-activated object, or can be as complex as defining a whole chain of IMessageSinks with custom properties.
通过.Net Remoting配置文件可以为Remote Objects设定许多参数,如Channel、SAO服务端激活对象类型(Singleton/SingleCall)等等,方便以后在不用修改代码或重新编译的情况下,改变Remote Objects的行为。
1,如下是Server端典型的Remoting配置文件:
xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http"/>
channels>
<service>
<wellknown mode="Singleton"
type="ComponentHost.CustomerManager, ComponentHost"
objectUri="CustomerManager.soap" />
service>
application>
system.runtime.remoting>
configuration>
(1)当Remote Objects部署在Console/Windows Form、Windows Services下时(上面的配置文件channel需要设置port属性),相应Server端声明Remote Objects的代码可以简化为:
string filename = "server.exe.config";
RemotingConfiguration.Configure(filename);
(2)如果Remote Objects部署在IIS时,根本就不需要任何代码声明。但是需要将上述配置文件命名为:web.config,并且将Remote Objects的DLL文件安置在web application的BIN文件夹。
一般在实际应用中,基本上将Remote Objects部署在IIS环境中,好处是(I)不需要编写额外的代码;(II)只要启动机器,远程对象就启动了。不需要你半夜三更跑到公司去登录,然后启动发生故障的远程服务;(III)容易与IIS认证服务进行集成;(IV)可能还有更多优点,我现在没有想到。
(3)如果需要声明多个远程对象,只需要在<service>与service>之间添加相应的Remote Objects配置信息即可。
(4)另外需要注意type属性为:
2,如下是Client端典型的配置文件:
xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="ComponentHost.CustomerManager, RemotingTest"
url="http://localhost/ComponentHost/CustomerManager.soap" />
client>
application>
system.runtime.remoting>
configuration>
要注意type属性的设定:
如果Client通过SoapSuds产生Remote Objects的元数据assembly,或者是Shared Assembly(如Interface或Abstract Class),这里则为上述assembly的名称。
如果是通过SoapSuds产生Source code,则为Client应用程序名(无exe后缀)。
同时,Client端application调用Remote Objects时,可以省掉:注册通道、Activator.GetObject()/RemotingConfiguration.RegisterActivatedServiceType()等代码,取而代之的代码为:
string filename = “clientApplication.exe.config”;
RemotingConfiguration.Configure(filename);
下面通过new来创建Remote Object实例。
3,标准的.Net Remoting Configuration配置文件
MSDN中有.Net Remoting Configuration file中全部元素/属性的完整的详细说明,需要的时候再查阅了。一般情况下,知道下面这些属性就够用了。
简单说明:
(1)
―― 配置要发布的CAO客户端激活对象的信息
(2)
When using CAOs, the
Note:When using CAOs from more than one server, you have to create several
当调用CAO远程对象时,必须设定
4,定制Client/Server Channel元素
(1)Client Side
<channel ref="http">
<clientProviders>
<formatter ref="binary" />
clientProviders>
channel>
其中,formatter ref=”binary” or “soap”。formatter ref指要在通道上发送的消息格式,在此示例中为二进制,以增强性能。
(2)Server Side
<channel ref="http">
<serverProviders>
<provider ref="wsdl" />
<formatter ref="binary" typeFileterLevel="Full" />
<formatter ref="soap" typeFileterLevel="Full" />
serverProviders>
channels>
typeFilterLevel表示当前自动反序列化级别,支持的值包括 Low(默认值)和 Full。
1. Ingo Rammer, Advanced .Net Remoting.
2. MSDN
Reference:
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- Inside ASP.NET 2.0-即时编译系统
- Asp.net 2.0自定义控件开发相关的几种嵌入资源解决方案
- 任务状态段和控制门
- Asp.net 2.0控件开发相关调试(JavaScript调试和自定义控件设计时调试)
- 给信息新鲜人
- .Net Remoting配置文件的用法
- Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载续][重点推荐控件]
- 修復VS.NET 2005
- 书评--信息经营法则
- Web.Config配置节加密和解密
- Asp.net 2.0 自定义控件开发专题[详细探讨页面状态(视图状态和控件状态)机制及其使用场景](示例代码下载)
- 招募 MS SQL DBA
- Asp.net 2.0自定义控件(点击HyperLink后执行事件)[网友问题: DataList里HyperLink控件激发事件,在哪定义?]
- 用AS3调用摄像头(附源代码下载)