实施.Net Remoting项目时出错 [英] Error in implement .Net Remoting project

查看:102
本文介绍了实施.Net Remoting项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在实施.Net Remoting Project,但出现了一些问题,请帮帮我.
我将代理对象编码为客户端和服务器之间的通讯方式为:

Hi all,
I''m implementing .Net Remoting Project but it occurs some problem, pls help me.
I code proxy object to comunicate between client and server as:

public class clsComponent : MarshalByRefObject
    {
        public DataSet TransDetails(string strServer)
        {
            string strConnectString = "server = " + strServer + "; database = ImperialBank; UID=phuc;PWD=phuc";
            SqlConnection sqlCon;
            SqlDataAdapter sqlDataApt;
            string strQuery = "Select Transaction_Id as 'Transaction Id', Transaction_Date as 'Transaction Date', " +
                               "Credit, Debit, Bal_Amt as 'Balance Amount' from Transactions";
            sqlCon = new SqlConnection(strConnectString);
            sqlDataApt = new SqlDataAdapter(strQuery, sqlCon);
            DataSet ds = new DataSet();
            sqlDataApt.Fill(ds, "Transactions");
            return ds;
        }
        public IQueryable<CustomerDetail> fnGetAllEmp()
        {
            var c = from c1 in db.CustomerDetails
                    select c1;
            return c;
        }
}


客户端已连接到服务器,客户端调用 TransDetails() =>好的.但是客户端调用 fnGetAllEmp(),则会发生错误:
在程序集"System.Data"中,


Client was connected to server and client call TransDetails() => ok. But client call fnGetAllEmp(), it occur error:

Type 'System.Data.Linq.DataQuery`1[[ComponentApp.CustomerDetail, ComponentApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.


对不起,我的语言!


Sorry my language!

推荐答案

就像错误提示System.Data.Linq.DataQuery对象必须具有Serializable属性一样,因为它是系统类,所以您不能做任何事情(BinaryFormatter序列化程序都需要这样做).

不要像这样编组对象,请使用Dataset.
Like the error says the System.Data.Linq.DataQuery object must have a Serializable attribute, since it is a system class then you can''t do anything about it (BinaryFormatter serializer requires this).

Don''t Marshal your objects like this, use the Dataset for this.


亲爱的,
我删除了 MarshalByRefObject ,它没有错误,尽管我使用LINQ运行方法.鲍比请给我清楚地解释一下!
Dear,
I removed MarshalByRefObject, it have no error although i run method using LINQ. Some boby please explain to me clearly!


这篇关于实施.Net Remoting项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆