0
votes

on my WCF Service I just change an enum from:

    /// <summary>
/// The DocumentState enum.
/// </summary>
[DataContract]
public enum DocumentState
{
    /// <summary>
    /// Undefined.
    /// </summary>
    [EnumMember]
    Undefined,

    /// <summary>
    /// OK.
    /// </summary>
    [EnumMember]
    Ok
}

to:

    /// <summary>
/// The DocumentState enum.
/// </summary>
[DataContract]
[Flags]
public enum DocumentState
{
    /// <summary>
    /// Undefined.
    /// </summary>
    [EnumMember]
    Undefined = 0,

    /// <summary>
    /// OK.
    /// </summary>
    [EnumMember]
    Ok = 1
}

On the client side I update the WCF References without any Problems but after rebuild I get:

Error 5 Custom tool error: Failed to generate code for the service reference 'MyService'. Please check other error and warning messages for details

Whats wrong with this flag enum?

UPDATE:

Ok.. in the warrnings I found this but this doesn't really helps me:

Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Referenced type 'TestSolution.Test.Entities.Documents.Document, TestSolution.Test.Entities, Version=1.1.78.7965, Culture=neutral, PublicKeyToken=7ad0fddf5c57b9b3' with data contract name 'Document' in namespace 'http://schemas.datacontract.org/2004/07/TestSolution.Test.Entities.Documents' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IDocumentService'] c:\TFS1\TestSolution - Test\Test\Test.Core\Service References\DocumentService\Reference.svcmap 1 1 Test.Core Warning 2 Custom tool warning: Cannot import wsdl:binding Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.

XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IDocumentService'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='NetTcpEndpoint'] c:\TFS1\TestSolution - Test\Test\Test.Core\Service References\DocumentService\Reference.svcmap 1 1 Test.Core Warning 3 Custom tool warning: Cannot import wsdl:port

Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='NetTcpEndpoint'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='DocumentService']/wsdl:port[@name='NetTcpEndpoint'] c:\TFS1\TestSolution - Test\Test\Test.Core\Service References\DocumentService\Reference.svcmap 1 1 Test.Core Error 4 Custom tool error: Failed to generate code for the service reference 'DocumentService'. Please check other error and warning messages for details. c:\TFS1\TestSolution - Test\Test\Test.Core\Service References\DocumentService\Reference.svcmap 1 1 Test.Core

1
UPDATE:Some additional informations for you: - I am using net.tcp binding - The enum is using in min. 50 places (with out the flags attribute) already on the wcf service and on the client - When I create a new enum with the same name but with a 2 at the end of the name all works great! What means really the warnings about the "wsdl:portType" / "wsdl:binding" / "wsdl:port" ????p__b_o

1 Answers

0
votes

When you added the Flag attribute, you changed the way the Enum is stored and made variables of that type capable of holding multiple values. This MSDN post explains the details on how WCF handles this. Unless you actually intend to make that Enum function as a flag field, I'd get rid of it since it needless complicates Enum meaning.