我在窗体中这样调用:
frmLogin.frmlogin.obj2.GetOrg(this.tvOrg);
传递的是一个树对象,可是运行的时候出现这样的错误
由于安全限制,无法访问类型 System.Runtime.Remoting.ObjRef
那位高手可以帮助解决一下吗?
因为我使用的是接口,而且项目采用的是三层结构
#region 树目录(行政区划)
        public void GetOrg(TreeView tv)
        {
            TreeNode t1 = new TreeNode();
            t1.Text = "xx市";
            t1.Tag = "";            
            tv.Nodes.Add(t1);            
            strSql = "select A.* from D201 as A,[s101-04] as B where A.districtCode=B.id and len(A.orgid)=" + 6 + "";
            DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
            foreach (DataRow datav in dv)
            {
                TreeNode tn = new TreeNode();
                tn.Text = datav["name"].ToString();
                tn.Name = datav["orgid"].ToString();                
                t1.Nodes.Add(tn);                         
                AddchildNodes1(tn);                
            }                    
        }
      
        private void AddchildNodes1(TreeNode tn)
        {
            //填充二级节点,他需要一级节点的value,所到干脆送了一个完整的根节点对象
            string orgid = tn.Name;
            strSql = "select * from D201 where len(orgid)=" + 8 + " and substring(orgid,1,6)=" + tn.Name + "";
            DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
            foreach (DataRowView datav in dv)
            {
                //循环数据视图,将对应的值交给一个节点对象,然后添加到树上有继续添加
                TreeNode ctn = new TreeNode();
                ctn.Text = datav["name"].ToString();
                ctn.Name = datav["orgid"].ToString();                
                tn.Nodes.Add (ctn);                  
            }
        }
    
        #endregion 树目录(行政区划)

解决方案 »

  1.   

    lz看这里吧:http://blog.csdn.net/liuzuofei/archive/2007/12/18/1947250.aspx
    我遇到过很多remoting的问题,在这里应该可以找到你的答案!
    记得给分!
      

  2.   

    哦,应该是你要传递的对象没有实现序列化,导致了这个错误!
    例如:如果你想传递oracleparam就会出这个错误,因为oracleparam不能远程传递!!
      

  3.   

     1.服务器chanle的安全设置。在2.0下,默认是不支持对象传送的。
     2。检查你传递的对象是否支持序列化!
      

  4.   

    好的,我的E-mial是:
    [email protected]
    解决了,马上结分
      

  5.   

    有关调用实时(JIT)调试而不是此对话框的详细信息,
    请参见此消息的结尾。************** 异常文本 **************
    System.Runtime.Serialization.SerializationException: 由于安全限制,无法访问类型 System.Runtime.Remoting.ObjRef。 ---> System.Security.SecurityException: 请求失败。
       在 System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedObject(RuntimeType type)
       在 System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)
    失败的操作是:
    Demand
    失败的第一个权限的类型是:
    System.Security.Permissions.SecurityPermission
    失败的第一个权限是:
    <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    version="1"
    Flags="Infrastructure"/>该请求用于:
    <PermissionSet class="System.Security.PermissionSet"
    version="1">
    <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    version="1"
    Flags="Infrastructure"/>
    </PermissionSet>唯一允许的权限是:
    <PermissionSet class="System.Security.PermissionSet"
    version="1">
    <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    version="1"
    Flags="SerializationFormatter"/>
    </PermissionSet>导致失败的方法是:
    System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Messaging.IMessage ByRef, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
       --- 内部异常堆栈跟踪的结尾 ---Server stack trace: 
       在 System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)
       在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)
       在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
       在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
       在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
       在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
       在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       在 System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
       在 System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)Exception rethrown at [0]: 
       在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       在 IDAL.IHomeAccount.FamilyIDInfo(HomeAccount model)
       在 SLxnhClient.Clinic.frmHomeAccount.btnQuery_Click(Object sender, EventArgs e) 位置 E:\WinForm\SLxnhWinForm\SLxnhClient\Clinic\frmHomeAccount.cs:行号 72
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** 已加载的程序集 **************
    mscorlib
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    SLxnhClient
        程序集版本: 1.0.0.0
        Win32 版本: 1.0.0.0
        基本代码: file:///E:/WinForm/SLxnhWinForm/SLxnhClient/bin/Debug/SLxnhClient.exe
    ----------------------------------------
    System.Windows.Forms
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    IDAL
        程序集版本: 1.0.0.0
        Win32 版本: 1.0.0.0
        基本代码: file:///E:/WinForm/SLxnhWinForm/SLxnhClient/bin/Debug/IDAL.DLL
    ----------------------------------------
    System.Configuration
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    Model
        程序集版本: 1.0.0.0
        Win32 版本: 1.0.0.0
        基本代码: file:///E:/WinForm/SLxnhWinForm/SLxnhClient/bin/Debug/Model.DLL
    ----------------------------------------
    System.Web
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
    ----------------------------------------
    mscorlib.resources
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Accessibility
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
    ----------------------------------------
    System.Windows.Forms.resources
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
    ----------------------------------------
    System.Data
        程序集版本: 2.0.0.0
        Win32 版本: 2.0.50727.42 (RTM.050727-4200)
        基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------************** JIT 调试 **************
    要启用实时(JIT)调试,
    该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
    jitDebugging 值。
    编译应用程序时还必须启用
    调试。例如: <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>启用 JIT 调试后,任何无法处理的异常
    都将被发送到在此计算机上注册的 JIT 调试器,
    而不是由此对话框处理。
      

  6.   

    BinaryServerFormatterSinkProvider tcpProvider = new BinaryServerFormatterSinkProvider();tcpProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;IDictionary tcpProps = new Hashtable();
                    tcpProps["port"] = ConfigClass.TcpPort;
                    System.Runtime.Remoting.Channels.Tcp.TcpServerChannel CustomTcpServerChannel = new TcpServerChannel(tcpProps, tcpProvider);
      

  7.   

    白雪公猪,我加了你的代码了,还是不行。我的客户端也用了full,并且客户端和服务器都是用app.config来设置的
      

  8.   

    我顶,自己顶,反正要实现三层架构,而且还要实现这个remoting,真的好难。我从不懂,变成一点,现在有问题了又解决不了。实在很烦
      

  9.   

    序列化问题,不要以为标了[Serializable]就一定可以序列化,尤其是和Control有关的对象
      

  10.   

    和Control有关的对象需要实现ISerializable接口,才有可能可以序列化,如果实现的有问题,一样也会出问题
    最好考虑序列化数据实体,而不是序列化和Control相关的对象
      

  11.   

    29楼,那我要在UI层实现TreeView的绑定啊。
    我是这样调的
    UI层直接这样调用的obj2.GetOrg(this.tvOrg );
    而model层为namespace Model
    {
        /// <summary>
        /// 实体类
        /// </summary>
        [Serializable]
        public class HomeAccount
        {
            public HomeAccount()
            { 
            }
            private TreeView tv;
           
            public TreeView Tv
            {
                set { tv = value; }
                get { return tv; }
            }
            
        }
    }
    接口类IDAL
    namespace IDAL

        public interface IHomeAccount
        {        /// <summary>
            /// 
            /// </summary>        DataTable GetHomeAccount();        /// <summary>
            /// 得到行政区域的数目录
            /// </summary>        void GetOrg(TreeView tv);
            //void GetOrg(ref HomeAccount model);
      
           
            SqlDataReader FamilyIDInfo(HomeAccount model);    }
    }
    业务逻辑类
    namespace BLL
    {
        /// <summary>
        /// 业务逻辑类LoginUser 的摘要说明。//该业务逻辑类继承于IDAL接口,涉及到数据工厂,实体类(引用)
        /// </summary>
        //MarshalByRefObject
        [Serializable]
        public class HomeAccount 
        {
            
            private readonly IHomeAccount dal=DataAccess.CreateHomeAccount();
            
            public HomeAccount()
            { }
            #region  成员方法        public DataTable  GetHomeAccount()
            {
                return dal.GetHomeAccount();           
                
            }        public void GetOrg(TreeView tv)
            {
                dal.GetOrg(tv);
            }
            //public void GetOrg(ref model.HomeAccount model)
            //{
            //    dal.GetOrg(ref model);
            //}        public SqlDataReader  FamilyIDInfo(model.HomeAccount model)
            {
               return  dal.FamilyIDInfo(model);
            }
            #endregion  成员方法
        }
    }
    数据访问类
    namespace AccessDAL
    {
        [Serializable]
        public class HomeAccount : MarshalByRefObject,IDAL.IHomeAccount
        {
            private string strSql;
            private string conn = SqlHelper.connectionString;
            public HomeAccount()            
            { }
            public DataTable GetHomeAccount()
            {
                strSql = "select * from D601";
                string conn = SqlHelper.connectionString;
                DataTable dt = SqlHelper.ExecuteTable(conn, CommandType.Text, strSql, null);
                return dt;        }
            # region 根据家庭ID来获取值 
            public SqlDataReader FamilyIDInfo(model.HomeAccount model)
            {            
                strSql = "select distinct top 1 A.* from  D601 as A,D401 AS B where A.familyID=B.familyID and B.familyID=@txtFamilyNo order by A.payDate desc";            
                SqlParameter[] parms = {
                    new SqlParameter("@txtFamilyNo", model.FamilyID)};            
                SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, strSql, null);          
                return dr;
            }
            # endregion 
                  
          
            #region 树目录(行政区划)        public void GetOrg(TreeView tv)
            {
                
                TreeNode t1 = new TreeNode();
                t1.Text = "南宁市";
                t1.Tag = "";            
                tv.Nodes.Add(t1);            
                strSql = "select A.* from D201 as A,[s101-04] as B where A.districtCode=B.id and len(A.orgid)=" + 6 + "";
                DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
                foreach (DataRow datav in dv)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = datav["name"].ToString();
                    tn.Name = datav["orgid"].ToString();                
                    t1.Nodes.Add(tn);                         
                    AddchildNodes1(tn);                
                }                    
            }
        
            private void AddchildNodes1(TreeNode tn)
            {
                //填充二级节点,他需要一级节点的value,所到干脆送了一个完整的根节点对象
                string orgid = tn.Name;
                strSql = "select * from D201 where len(orgid)=" + 8 + " and substring(orgid,1,6)=" + tn.Name + "";
                DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
                foreach (DataRowView datav in dv)
                {
                    //循环数据视图,将对应的值交给一个节点对象,然后添加到树上有继续添加
                    TreeNode ctn = new TreeNode();
                    ctn.Text = datav["name"].ToString();
                    ctn.Name = datav["orgid"].ToString();                
                    tn.Nodes.Add (ctn);                  
                    AddchildNodes2(ctn);
                }
            }
           
            private void AddchildNodes2(TreeNode tn)
            {
                //填充三级节点,他需要一级节点的value,所到干脆送了一个完整的根节点对象
                string orgid = tn.Name;
                strSql = "select * from D201 where len(orgid)=" + 10 + " and substring(orgid,1,8)=" + tn.Name + "";
                DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
                foreach (DataRowView datav in dv)
                {
                    //循环数据视图,将对应的值交给一个节点对象,然后添加到树上有继续添加
                    TreeNode ctn2 = new TreeNode();
                    ctn2.Text = datav["name"].ToString();
                    ctn2.Name = datav["orgid"].ToString();
                    tn.Nodes.Add (ctn2);
                    AddchildNodes3(ctn2);
                }
            }
           
            private void AddchildNodes3(TreeNode tn)
            {
                //填充四级节点,他需要一级节点的value,所到干脆送了一个完整的根节点对象
                string orgid = tn.Name;
                strSql = "select * from D201 where len(orgid)=" + 12 + " and substring(orgid,1,10)=" + tn.Name + "";
                DataView dv = SqlHelper.ExecuteDataView(conn, CommandType.Text, strSql, null);
                foreach (DataRowView datav in dv)
                {
                    //循环数据视图,将对应的值交给一个节点对象,然后添加到树上有继续添加
                    TreeNode ctn3 = new TreeNode();
                    ctn3.Text = datav["name"].ToString();
                    ctn3.Name = datav["orgid"].ToString();
                    tn.Nodes.Add(ctn3);
                }
            }
            #endregion 树目录(行政区划)    }
    }
    其他的都可以实现,就是这个树目录不能实现啊
    29楼,你可以给一下这些方面的资料给我吗?我的联系方式上面都有,真的谢谢啊。好人
      

  12.   

    1、分层方面的问题,DAL引用到TreeView和TreeNode这些UI的东西本身就是一个错误(什么时候把工程移植到WebForm,你就知道错在哪里了)
    2、3层构架没有数据实体和框架的部分,3层构架不是只有3个部分组成的,除了那3层外,还要有一个数据实体和一个框架,这两个是被3层的所依赖的(不然数据往哪里扔?Utility往哪里扔?)
    3、DAL只负责获得数据实体的对象,BLL部分对数据做各种处理,UI部分只负责把数据实体对象绑定到UI的控件上
    4、偷懒的话,可以把DataSet当数据实体(不太雅观)
      

  13.   

    楼上的,你加一下我的QQ啊,要不留你的QQ也可以。要不发一份remoting的给我。我的e_mail是:[email protected]
      

  14.   

    不用qq
    remoting的资料网上有很多,有很多还有例子(真的很多,在google里面搜索“remoting 例子”,就可以找到一大堆)
      

  15.   

    晕。问题是我现在的程序,有些用remoting就可以成功了,只是这个不能成功而已。我用三层结构的,以下这条语句就可以通过remoting访问了(dataGridView)
     this.dgvHomeAccount.DataSource = frmLogin.frmlogin.obj2.GetHomeAccount();
    但是我用树的时候就不行就出现这种情况。
    remoting的基本原理懂啊。问题是。算了。
      

  16.   

    是这样子的,什么时候你要让TreeView序列化,什么时候就出错,所以尽量不要让控件去Remoting,会带来很多麻烦
    想这样的问题,可以建立一个树形的数据对象,
    假设定义一个叫ITreeRoot的对象描述这个树
    void GetOrg(TreeView tv);修改为ITreeRoot GetOrg();
    BLL需要处理什么就处理一下,最后交给UI,UI把ITreeRoot里面的数据绑定到TreeView,因为结构相似,可以很简单的实现
      

  17.   

    怪不得,原来你使用TreeView上传。你可以考虑使用自定的对象,模拟Treeview和TreeNote。
      

  18.   

    还没明白啊,不要传TreeView,因为传TreeView违反了太多的OO原则
    告诉你怎么让TreeView穿过Remoting也没什么意义,如果这个结构是lz设计的,建议去补课,如果不是,建议让设计的人去补课
      

  19.   

    不是我设计的,是我同事。但是不可能叫别人去弄的。41楼,如果不传TreeView,那我UI层的树怎么获取到数据呢?你可以明白点告诉我吗?其他的查询表什么的我都可以通过Remoting实现了,就差这个了,我想实现树目录啊。
      

  20.   

    建立一个树形结构的数据对象,到UI再把这个树形结构的数据对象显示到TreeView上附:
    怎么定义树形结构的数据对象,写类啊
    怎么把树形结构的数据对象显示到TreeView上,根据数据对象,有一个数据对象的节点就去new一个TreeNode
      

  21.   

    可是TreeView怎么获得数据对象?
      

  22.   

    以前没有用三层的时候都能够调出树目录的。现在用了三层,而且加上Remoting的时候却不能了
      

  23.   

    怎么还不开窍呢?
    也就是说在Business Layer 不要去操作UI上的东西。不要传递TreeView 。Business Layer 只负责业务数据的组合操作。也就是向UI的TreeView 提供必需的数据。你想想 TreeView 加载的是什么?最终都是数据。不晓得是 vwxyzh和我  没说明白,还是你根本认为这样做是对的。有时候换种思维比较好! 你说你的问题没法解决,我们提出了意见你又觉得不妥,不愿意尝试修改,你就让这个Bug 一直留着?一直不解决,你就一直拖着?
      

  24.   

    好,送佛送到西 给你说思路:建立一个Note 类 ,这个类包含 
    Name(string),Description (string),ParentNote (Note),ItemNote
    (CollectionBase)等几个Property。然后建立一个派生与CollectionBase的Collection 操作 对象 Note。重写 CollectionBase的this[],Add 方法和属性。例如,在Add 方法中将加入这个Collection的Note 下的ParentNote 设置为当前的Note。在Bl 组装后,向下传送 Collection ,UI接受后,遍历这个列表,完成你的TreeView的加载!
      

  25.   

    上面的各位说得很清楚了,我只是打几个比喻.
    1. 实体类HomeAccount还带一个界面的控件.如果你去登记,带身分证户口就好了,不用把房子背去.
    2. 序列化的类才可以序列化,一个小积木拆了可以复原,一辆汽车肢解了就很难复原了.连MS也没有做这种吃力不讨好的事情.LZ可以省点时间.
    3. 你同事的这个层可以用.就如上面有位已经介绍过的,传出来一个dataset就好了.估计你的homeaccount没有算到几十代去的.
      界面: TreeHelp.LoadTree(this.Treeview1,BLL.Ihomehelp.GetHomeMember());
     I.   Fecade: TreeHelp.LoadTree(Treeview tv,Dataset ds){} 
     II.  BLL: Datatable Ihomehelp.GetHomeMember(){}
     III. DAL: Datatable Dalhomehelp.GetHomeMember(){ ...getdata...}大约是这个样子,这样不用改变你同事的代码.只是在加一个界面呈现的类去获取应该得到的数据.
    我也不知道这样会不会更清楚些了,或是要你的同事可以把改版重新编译一次?
      

  26.   

    按照上面的去做。构造了一棵树,可是又出现了新的情况:“未将对象引用到对象的实例"
    下面把代码贴出
    1、模型 
    using System;
    using System.Collections.Generic;
    using System.Text;namespace Model
    {
        /// <summary>
        /// 节点
        /// </summary>
        [Serializable]
        public class Node
        {
            private string name;//结点名称
            private string text;//显示的文本
            private string tag;//节点值        public string Name
            {
                set
                {
                    name = value;
                }
                get
                {
                    return name;
                }
            }
            public string Text
            {
                set
                {
                    text = value;
                }
                get
                {
                    return text;
                }
            }        public string Tag
            {
                set
                {
                    tag = value;
                }
                get
                {
                    return tag;
                }
            }
        }
    }2、业务
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    using DBUtility;
    using Model;
    using IDAL;namespace AccessDAL
    {
        [Serializable]
        public class TreeView:MarshalByRefObject,IDAL.ItreeView
        {
            public TreeView()
            {
            }        private string strSql;        #region ItreeView 成员
    /// <summary>
    /// 
    /// </summary>
    /// <param name="_node"></param>
    /// <returns></returns>      
            public Node[] GetViewData(Model.Node _node)
            {           
                
                if (_node.Name == "123456")//当树为空时,返回数据--(x,123456)
                {                Node[] _ArrNode = new Node[1];
                    _ArrNode[0].Name = _ArrNode[0].Tag = "123456";
                    _ArrNode[0].Text = "x";
                    return _ArrNode;
                }
                else if (_node.Tag == "123456")//当选择x结点时,返回
                {
                    strSql = "select A.* from D201 as A,[s101-04] as B where A.districtCode=B.id and len(A.orgid)=" + 6 + "";
                    string conn = SqlHelper.connectionString;
                    DataTable dt = SqlHelper.ExecuteTable(conn, CommandType.Text, strSql, null);
                    Node[] _ArrNode = new Node[dt.Rows.Count];
                    if (dt.Rows.Count == 0)
                    {
                       return _ArrNode; 
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        _ArrNode[i].Name = dt.Rows[i]["A.orgid"].ToString();
                        _ArrNode[i].Text = dt.Rows[i]["A.name"].ToString();
                        _ArrNode[i].Tag = dt.Rows[i]["A.orgid"].ToString();
                    }
                    return _ArrNode;            }
                else//当选择其他结点时,
                {
                    int Len = _node.Tag.Length;
                    strSql = "select * from D201 where len(orgid)=" + Len+2+"and substring(orgid,1,"+Len+")=" + _node.Tag + "";
                    string conn = SqlHelper.connectionString;
                    DataTable dt = SqlHelper.ExecuteTable(conn, CommandType.Text, strSql, null);
                    Node[] _ArrNode = new Node[dt.Rows.Count];
                    if (dt.Rows.Count == 0)
                    {
                        return _ArrNode;
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        _ArrNode[i].Name = dt.Rows[i]["orgid"].ToString();
                        _ArrNode[i].Text = dt.Rows[i]["name"].ToString();
                        _ArrNode[i].Tag = dt.Rows[i]["orgid"].ToString();
                    }
                    return _ArrNode;
                }
                
            }        #endregion
        }
    }
    3、界面
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace SLxnhClient
    {
        public partial class tree : Form
        {
            public IBLL.ITreeView obj;
            public Model.Node _node = new Model.Node();
            public tree()
            {
                InitializeComponent();
            }        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
            {
                _node.Name = treeView1.SelectedNode.Name.ToString();
                _node.Text = treeView1.SelectedNode.Text.ToString();
                _node.Tag = treeView1.SelectedNode.Tag.ToString();            obj = frmLogin.frmlogin.myBllBuild.GreatTreeView();
                for (int i = 0; i < obj.GetViewData(_node).Length; i++)
                {
                    if (treeView1.SelectedNode == null)
                    {
                        MessageBox.Show("请选择一个节点", "提示信息",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        //创建一个节点对象
                        TreeNode tmp;
                        tmp = new TreeNode();
                        tmp.Name = obj.GetViewData(_node)[i].Name;
                        tmp.Text = obj.GetViewData(_node)[i].Text;
                        tmp.Tag = obj.GetViewData(_node)[i].Tag;
                        //在TreeView组件中加入子节点
                        treeView1.SelectedNode.Nodes.Add(tmp);
                    }
                }
            }        private void tree_Load(object sender, EventArgs e)
            {            
                if (treeView1.Nodes.Count == 0)
                {
                    try
                    {
                        obj = frmLogin.frmlogin.myBllBuild.GreatTreeView();
                        _node.Name = "";
                        _node.Tag = "";
                        _node.Text = "";
                        obj.GetViewData(_node);                    
                       
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }
            }
        }
    }
      

  27.   

    服务器段配置通道中,修改为一下方式
    <channels>
            <channel ref="tcp" port="端口">
              <serverProviders>
                <provider ref="wsdl" />
                <formatter ref="soap" typeFilterLevel="Full"/>
                <formatter ref="binary" typeFilterLevel="Full" />
              </serverProviders>
            </channel>
    </channels>