-1

I have been successfully sending objects using a WCF service, but there is one class that doesn't work. The WCF service will build, and I can invoke the function that returns the object in the WCF Test Client, but I cannot use the service once I have updated the service reference in the project that's the consumer.

Here is a copy of the class

//[Serializable]
[DataContract]
public class TillCompanySystem : INotifyPropertyChanged
{

    // Internal private member variables
    private String _sTillCompanySystemID = "";
    private String _sValue = "";

    // Events
    //[field: NonSerialized]
    public event PropertyChangedEventHandler PropertyChanged;

    // Constructor
    public TillCompanySystem()
    {

    }

    // Public properties
    #region Public Properties

    // Public properties
    [DataMember]
    public String TillCompanySystemID
    {
        get { return _sTillCompanySystemID; }
        set
        {
            _sTillCompanySystemID = value;
            OnPropertyChanged(new PropertyChangedEventArgs("TillCompanySystemID"));
        }
    }

    [DataMember]
    public String Value
    {
        get { return _sValue; }
        set
        {
            _sValue = value;
            OnPropertyChanged(new PropertyChangedEventArgs("Value"));
        }
    }

    // End region public properties
    #endregion

    // All objects need to support ToString
    public override String ToString()
    {
        return TillCompanySystemID.ToString();
    }

    // Public Events
    public void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, e);
    }
}

I really have no idea why this doesn't work. The only difference I can think of between this and other classes is that previously it was serializable, but I can't see how that would make any difference now. However, if I view the class from the metadata the class still appears to be serializable. I have tried rebuilding everything and that hasn't fixed it.

Does anyone have any ideas?

Thanks in advance

Ed

4
  • 3
    In what way can't you use the service? Do you get an error?
    – Paddy
    Jul 9, 2013 at 10:56
  • I've tried a quick test app and the entity is returned as expected. Of course, only the public properties (DataMembers) are serialized. i.e. the server implementations of ToString() and OnPropertyChanged aren't pulled across to the client proxy class. The INotifyPropertyChanged interface is recognized by Visual Studio during proxy generation and is re-implemented in the proxy.
    – StuartLC
    Jul 9, 2013 at 11:05
  • When I update the service reference, there is no service that is available. I right click on the service reference and view in object browser, the service is not available. I have seen this previously when I have added new functions to the service and have not made the classes datacontracts. Jul 9, 2013 at 11:26
  • 1
    How do you return this class from your service? I mean is it possible to show the method returning this Class (or perhaps accepting it as parameter)?
    – vibhu
    Jul 9, 2013 at 19:15

1 Answer 1

0

The reason that it wasn't working was that the someone had made the project reference a compiled version of the datalayer project which meant that this class was always accessible and I have been able to add new classes to the project and it found them, but it wouldn't rebuild this particular class to make it a datacontract since it existed in compiled form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.