none
Using Linq-To-Sql with Remoting? RRS feed

  • Question

  • Hi

    I'm trying to use Linq-To-Sql with .Net Remoting but I'm running into various issues.  Firstly, all the objects are decorated with the DataContract attribute, not the default Serializable attribute.  Also, there is no way to specify this in the designer.  Secondly, the EntitySet and EntityRef types are not serializable by default.  How am I supposed to use Linq-To-Sql with .Net Remoting?

    The only way that I can see that this could possibly work is if I serialize the objects myself using the NetDataContract serializer.  However, this doesn't actually seem possible since I cannot decorate an object with the DataContract attribute AND implement ISerializable.  I don't know why this constraint exists?  Another way of making this all work would be to add a SerializationSurrogate to the BinaryFormatter used for remoting and in this surrogate class simply invoke the NetDataContract serializer.  This could theoretically work, but I can't seem to find a way of getting a handle on the Binary Formatter used by the remoting infrastructure to add my surrogate?  Or should I implement a custom formatter (which is an insane amount of work simply to get the default behaviour working...)?

    Did the designers of Linq-To-Sql go out of their way to prevent the use of Linq-To-Sql classes with .Net remoting?

    Thanks
    Tuesday, October 7, 2008 9:26 AM