Search code examples
c#web-serviceswcfvisual-studio-2015

WCF Updating Service References doesn't add new properties


I created a Backend-Service (Windows-Service) which provides data to my Network-Clients over WCF, handles the connection to the Database and some specific tasks.

Every time when I changed something in my DTO-Objects the changes were made correctly on the client side when I update the service-reference.

But now the Update-Process does not create the correct proxy for the WCF-Service. When I add some DTO-Objects the information about the new DTO's updated correctly to the client but when I add some properties to existing DTO-Objects the Update-Servicereference Function does not include the new Properties. I already tried to create a completely new application and add the Service-Reference within this Test-Scenario but also in this case the new property does not appear in the proxy-class.

First time I noticed this behaviour was as I try to create a new property in my "File.cs" DTO. I thought that the name "File" (the class definition has the same name) creating this error. So I decided to rename the "File" DTO-Class to AttachmentFile and the new properties are created correctly on the proxy.

But now I try to add Properties to the Classes DeviceStayType and ProcessStateType and there's the same behaviour. No Error is displayed and the Git says that the proxy changed when I press Update Service-References but the properties are still missing on the client side.

Here are some snippets:

The old DeviceStayType-Class:

    [DataContract]
public class DeviceStayType : TypesBase
{
}

The new DeviceStayType-Class:

    [DataContract]
public class DeviceStayType : TypesBase
{
    [DataMember(Name = "TableName")]
    [MaxLength(200)]
    public string TableName { get; set; }
}

The generated Proxy for the DeviceStayType

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="DeviceStayType", Namespace="http://schemas.datacontract.org/2004/07/ProductLifecycle.Backend.Models.DTO")]
[System.SerializableAttribute()]
public partial class DeviceStayType : ProductLifecycle.Frontend.CommunicationService.TypesBase {
}

Hope that anyone can help


Solution

  • OK. After some tests i decided to outsource the Models in an DLL which both projects (backend and frontend) have a reference for. It seems that this was the only way to fix this issue. I think this behaviour is produced when theree are two webservices; one in the frontend as Callback (Streamed because theres a much better performance) and one in the backend as Managing-Service. Both services used the same classes and i thought this could be a possible reason because the Backend-Service sends the Models to the Frontend-Client and the Frontend-Service sends the Models to the Backend-Client as well. Now with the outsourced classes and much lighter conversions the scenario works in my case.