none
My WCF Service won't return one particular class RRS feed

  • Question

  • 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

    • Moved by Caillen Wednesday, July 10, 2013 6:07 AM
    Tuesday, July 9, 2013 11:11 AM

Answers

  • Hi,

    >> but I cannot use the service once I have updated the service reference in the project that's the consumer.

    Can you explain the issue more clearly? Is there any error message?

    I would also suggest you enable tracing for your service to help to diagnose the issue, and use SvcTraceViewer.exe tool to analyze the diagnostic traces.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 10, 2013 6:28 AM
    Moderator
  • Thanks for your help.

    I found the problem in the end, and that was that the project was referencing a compiled version of the datalayer as well as the project version. I have been updating and adding classes which have been fine, but I would guess that this class happened to exist in the compiled version and so didn't reflect the changes I'd made to make it a datacontract.

    Thanks again.

    Thursday, July 11, 2013 8:49 AM

All replies

  • Hi,

    >> but I cannot use the service once I have updated the service reference in the project that's the consumer.

    Can you explain the issue more clearly? Is there any error message?

    I would also suggest you enable tracing for your service to help to diagnose the issue, and use SvcTraceViewer.exe tool to analyze the diagnostic traces.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 10, 2013 6:28 AM
    Moderator
  • There's no error message. The consumer project can no longer access the public class Service1Client that contains all of the methods of my service. That means I can't instantiate it in my consumer project, or view it in the object explorer, despite the fact that the reference to my service still exists. I also can't see that there is any problem with the service since the WCF Test Client allows me to access all the methods as expected, and will return the class shown above as expected.

    If I comment out the operation contract in the interface that returns an instance of TillCompanySystem the consumer can access all of the functions I would expect it to, if not it doesn't. The method in question currently only returns a TillCompanySystem object that I have created, and so I can only assume that it's the class TillCompanySystem class itself which is the issue. There's nothing that I can see that is wrong with the class though. Do you have any ideas what I could try to do to overcome this problem?

    Thanks for your help.

    Ed

    Wednesday, July 10, 2013 9:06 AM
  • Hi,

    >> I also can't see that there is any problem with the service since the WCF Test Client allows me to access all the methods as expected, and will return the class shown above as expected.

    Do you mean the service can be accessed as expected by WCF Test Client but not for a real client? Please try delete the service reference and then re-add the service reference for the client.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 11, 2013 2:24 AM
    Moderator
  • Thanks for your help.

    I found the problem in the end, and that was that the project was referencing a compiled version of the datalayer as well as the project version. I have been updating and adding classes which have been fine, but I would guess that this class happened to exist in the compiled version and so didn't reflect the changes I'd made to make it a datacontract.

    Thanks again.

    Thursday, July 11, 2013 8:49 AM