views:

20

answers:

1

I have a class like so

[DataContract]
public MyClass
{
  private string _Name;
  private bool _NameIsModified = false;

  public string Name;
  {
    get { return _Name; }
    set 
    {
      _Name = value;
      _NameIsModified = true;
    }
  }
}

When a clients requests this class via a WCF service modifies the objects and sends it back to the server the _NameIsModified is not being set. (I totally see what this is happening).

On both the server and client I have access to MyClass. Is it be possible to retrieve the Proxy MyClass and cast it to a new instance of MyClass or have the WCF service load it directly into a MyClass instance.

A: 

No, you can't do it directly by casting. You will have to write some code client-side to clone the proxy version of the object to the same type the server is using. (The proxy classes are created as partial classes so you can just extend them).

An alternative to this is to ensure your client side actually references the same assemblies as the server, once you have done this then you may need to manually edit the proxy generated classes to remove the duplicate class declarations.

How to do this sharing of classes between server and client has been covered heaps here on SO, i'll see if i can dig some useful posts out a little later on.

slugster