Duwamish模式的Remoting注意事项(Remoting高手可以不必看了)

我是一个Remoting新手。所以请大家不要丢砖头。
本文采取的方式是以IIS作为Remoting宿主。
服务器端
1。数据层
    以DataSet或者继承于DataSet为基类
    类上方表明[Serializable]属性
    实现
 
        private VersionDataSet(SerializationInfo info, StreamingContext context) : base(info, context)
        
{
        }
一个私有的构造函数,继承于DataSet,用于序列化。
    如果需要在DataColumn中添加信息的话,可以写入ExtendedProperties中
2。Interface层
    抽象出所有操作的方法,
3。Rule层
     实现Interface层的操作,继承于MarshalByRefObject
     需要返回数据集的,必须Return或者out方式返回。
4. Web层
     引用Rule层。
     编写Web.Config
<configuration>
  
<system.runtime.remoting>
    
<application>
      
<service>
          
        
<wellknown mode="Singleton" 
                   type
="pensharp.BusinessRules.CheckUserRightRule, pensharp.BusinessRules" 
                   objectUri
="CheckUserRightRule.soap" /> 
      
</service>
    
</application>
  
</system.runtime.remoting>
</configuration>

本文使用Singleton方式。
客户段
  1。引用Data层,和Interface层
       建立一个RemotingUtility.cs文件,
      建立静态的方法来获取Remoting对象。
        public static ICheckUserRight GetCheckUserRight()
        
{
            
return (ICheckUserRight)Activator.GetObject(typeof(ICheckUserRight),"http://172.26.1.28/pensharpRemoting/CheckUserRightRule.soap");
        }

       剩下的就是利用接口来操作数据了。

原文地址:https://www.cnblogs.com/wildfish/p/64732.html