我传了个Combobox过去 老是出现:
由于安全限制,无法访问类型 System.Runtime.Remoting.ObjRef。
远程对象的方法:
public void FillComboBox(ref ComboBox combo,int nIndex, int SM)
        {
            
            combo.Items.Clear();
            SqlCommand command = new SqlCommand("select * from CW_Accountant_code where nIndex =" + nIndex.ToString() , Conn);
            SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (dr.Read())
            {
                combo.Items.Add(dr["SM" + SM.ToString()].ToString());
            }
            dr.Close();
            
        }
客户端:
 DataBaseObject dataobj = new DataBaseObject(((AccType)item.Tag).Data);
            Common.DataObj = dataobj;
            dataobj.FillComboBox(ref comboBox1,2, 1);

解决方案 »

  1.   

    FillComboBox(ComboBox combo,int nIndex, int SM)
    没必要要ref
      

  2.   

    即使FillComboBox(ComboBox combo,int nIndex, int SM) 这样也是会出现上面说的错误。
      

  3.   

    想不通,仅仅是为了填充数据,为什么要传个combobox回去...在客户端写个方法把取得的数据绑到combobox上不更有效率么...
      

  4.   

    DataBaseObject 这个继承MarshalByRefObject了么?
      

  5.   

    hdt(倦怠) : 远程传递需要实现序列化,且控件是不能传递的,因为它依赖于本地太多可以的吧. MSDN:Component 可以进行远程处理,它从 MarshalByRefObject 派生
      

  6.   

    纠正个错误继承与MarshalByRefObject并不能被传递到另一端,而是客户端通过代理远程调用
      

  7.   

    DataBaseObject 这个继承MarshalByRefObject了么?
    namespace RemoteObject
    {   
       
        [Serializable]
        #region 数据类
        public class DataBaseObject : MarshalByRefObject
        {
        }
        #endregion
      

  8.   

    配置文件里加这个呢?
     <formatter ref="soap" typeFilterLevel="Full" />
          <formatter ref="binary" typeFilterLevel="Full" />另外[Serializable]是不用的
      

  9.   

    我没用到配置文件 我是在程序里设置的RemotingConfiguration.ApplicationName = "RemoteObject";
    RemotingConfiguration.RegisterActivatedServiceType(typeof(DataBaseObject));
      

  10.   

    TcpChannel channel = new TcpChannel();
                ChannelServices.RegisterChannel(channel);
             
                    
                    RemotingConfiguration.RegisterActivatedClientType(
                       typeof(DataBaseObject), "tcp://192.168.0.15:8000/RemoteObject");
                    DataBaseObject dataobj = new DataBaseObject(((AccType)item.Tag).Data);
                Common.DataObj = dataobj;
      

  11.   

    我懒得看怎么写了,好久没用了。MSDN上的文章你自己看吧-------------------------------依赖于运行时类型验证的远程处理系统必须反序列化一个远程流,然后才能开始使用它,未经授权的客户端可能会试图利用反序列化这一时机。为了免受这种攻击,.NET 远程处理提供了两个自动反序列化级别:Low 和 Full。Low(默认值)防止反序列化攻击的方式是,在反序列化时,只处理与最基本的远程处理功能关联的类型,如自动反序列化远程处理基础结构类型、有限的系统实现类型集和基本的自定义类型集。Full 反序列化级别支持远程处理在所有情况下支持的所有自动反序列化类型。警告   不要以为控制反序列化是应用程序需要的唯一安全机制。在分布式应用程序中,即使严格控制序列化也不能防止这种危险的发生:即未经授权的客户端截获通信内容,然后以某种方式利用该通信内容,即使只是向其他用户显示数据,也会造成损害。因此,虽然 Low 反序列化级别对某些基于自动反序列化的攻击类型提供了一定的保护,但您仍然必须考虑是否使用身份验证和加密来为您的数据提供完全的保护。有关详细信息,请参见安全性。
    下面的列表描述 .NET 远程处理反序列化级别: Low(默认级别) 
    .NET 远程处理中的默认反序列化级别支持以下类型的反序列化: 远程处理基础结构对象。它们是在基本级别进行远程处理时所需的类型。 
    基元类型以及由基元类型构成的引用类型和值类型。 
    用 SerializableAttribute 属性标记但未实现 ISerializable 接口的引用类型和值类型。 
    实现 ISerializable 并且未发出序列化之外的其他任何要求的系统提供类型。 
    实现 ISerializable(或者用 SerializableAttribute 标记)并位于未用 AllowPartiallyTrustedCallersAttribute 属性标记的程序集中的系统提供类型。 
    具有强名称并且位于未用 AllowPartiallyTrustedCallersAttribute 属性标记的程序集中的自定义类型。 
    实现 ISerializable 并且未发出序列化之外的其他任何要求的自定义类型。 
    实现 ILease 接口并且不属于 MarshalByRefObject 对象的类型。 
    用于激活(以支持客户端激活的对象)的 ObjRef 对象;也就是说,客户端可以反序列化返回的 ObjRef,但服务器却不能。 
    Full 
    .NET 远程处理中的 Full 反序列化级别支持其他所有方案,包括以下附加类型的反序列化: 作为参数传递的 ObjRef 对象。 
    实现 ISponsor 接口的对象。 
    由 IContributeEnvoySink 接口在代理和客户端管线之间插入的对象。 
    如果应用程序需要使用仅在 Full 反序列化级别才可用的远程处理功能,您必须提供身份验证的类型和必要的加密级别,以保护任何在使用远程方案中的这些高级功能时可能遭受风险的资源。 您可以通过编程方式或使用应用程序配置文件设置反序列化级别。以编程方式设置反序列化级别
    若要以编程方式设置反序列化级别,请在创建时将以下属性传递给 SoapServerFormatterSinkProvider 对象或 BinaryServerFormatterSinkProvider 对象。然后,当该值插入到接收链中时,远程处理系统将在格式化程序上设置该值。以下示例说明如何在宿主应用程序域中将反序列化级别设置为 Full。[C#]// Creating a custom formatter for a TcpChannel sink chain.BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();provider.TypeFilterLevel = TypeFilterLevel.Full;// Creating the IDictionary to set the port on the channel instance.IDictionary props = new Hashtable();props["port"] = 8085;// Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)TcpChannel chan = new TcpChannel(props, null, provider);[Visual Basic]' Creating a custom formatter for your TcpChannel sink chain.Dim provider As New BinaryServerFormatterSinkProvider()provider.TypeFilterLevel = TypeFilterLevel.Full' Creating the IDictionary to set the port on the channel instance.IDictionary props = new Hashtable()props("port") = 8085' Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)Dim chan As New TcpChannel(props, null, provider)
      

  12.   

    此远程处理代理没有信道接收,这意味着服务器没有正在侦听的已注册服务器信道,或者此应用程序没有用来与服务器对话的适当客户端信道
    现在错误变这样了服务端:
     BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();                provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;                // Creating the IDictionary to set the port on the channel instance.                IDictionary props = new Hashtable();                props["port"] = 8000;                // Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)                TcpChannel Channel = new TcpChannel(props, null, provider);
                    ChannelServices.RegisterChannel(Channel);
      

  13.   

    该对象的其他方法都正常 就是这个方法不能用 
    是否不能传递ComboBox combo这个东西过去?