none
Problem with Remoting and Generated Entity Classes RRS feed

  • Question

  • We cannot seem to pass our L2S entity classes to a client process via remoting. It works ok with WCF. Are there known issues with using L2S entity classes with remoting?

    Randy

    Sunday, November 8, 2009 7:49 PM

Answers

All replies

  • Hi Randy,

     

    Yes, LINQ to SQL does not serialization using .NET Remoting.  Here is one LINQ to SQL FAQ from Matt Warren:

     

    Q: How do I serialize entities using .Net Remoting?

    A: LINQ to SQL does not support serialization using .Net Remoting.  Key data types such as EntityRef and EntitySet are not serializable.”

     

    It is recommended to serialize the entities as XML via WCF.  For detail, please see other related FAQs here, http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/3ae5e457-099e-4d13-9a8b-df3ed4ba0bab/.

     

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 9, 2009 1:24 AM
    Moderator
  • By default, the generated entity classes are not setup to be marshal-by-value or marshal-by-reference for remoting. In order to do the former you will need to declare partial classes for each of your entity classes you want to marshal and apply the SerializableAttribute to the class. If you want to make them marshal-by-reference, you can either declare partial classes and set the base class to System.MarshalByRefObject, or you can set the EntityBase attribute on the Database element in the DBML file to System.MarshalByRefObject.

    <Database ... xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007" EntityBase="System.MarshalByRefObject" >

    Will that help? Or have you tried that already and noticed that there is a problem?
    Blog - http://blogs.rev-net.com/ddewinter/ Twitter - @ddewinter
    Monday, November 9, 2009 1:36 AM
    Answerer