Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
C#
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;
        }
}

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!
Posted

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.
 
Share this answer
 
Comments
VJ Reddy 22-May-12 3:49am    
Good answer. 5!
Mehdi Gholam 22-May-12 4:48am    
Thanks VJ!
Dear,
I removed MarshalByRefObject, it have no error although i run method using LINQ. Some boby please explain to me clearly!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900