我只需更改枚举:
/// <summary>
/// The DocumentState enum.
/// </summary>
[DataContract]
public enum DocumentState
{
/// <summary>
/// Undefined.
/// </summary>
[EnumMember]
Undefined,
/// <summary>
/// OK.
/// </summary>
[EnumMember]
Ok
}
为:
/// <summary>
/// The DocumentState enum.
/// </summary>
[DataContract]
[Flags]
public enum DocumentState
{
/// <summary>
/// Undefined.
/// </summary>
[EnumMember]
Undefined = 0,
/// <summary>
/// OK.
/// </summary>
[EnumMember]
Ok = 1
}
在客户端,我更新了WCF引用而没有任何问题,但在重建后我得到:
错误5自定义工具错误:无法为服务引用“MyService”生成代码。有关详细信息,请查看其他错误和警告消息
这个标志enum有什么问题?
更新
好的..在我发现的这些警告中,但这对我没有帮助:
警告1自定义工具警告:无法导入wsdl:portType 详细信息:运行WSDL导入扩展时抛出异常:System.ServiceModel.Description.DataContractSerializerMessageContractImporter 错误:引用类型'TestSolution.Test.Entities.Documents.Document,TestSolution.Test.Entities,Version = 1.1.78.7965,Culture = neutral,PublicKeyToken = 7ad0fddf5c57b9b3',命名空间'http:// schemas中的数据协定名称为'Document' .datacontract.org / 2004/07 / TestSolution.Test.Entities.Documents'无法使用,因为它与导入的DataContract不匹配。需要从引用的类型中排除此类型。
XPath到错误来源://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 警告2自定义工具警告:无法导入wsdl:binding 详细信息:导入wsdl:binding依赖的wsdl:portType时出错。
XPath to wsdl:portType://wsdl:definitionf [@targetNamespace ='http://tempuri.org/']/wsdl:portType [@ name ='IDocumentService'] XPath到错误源://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 警告3自定义工具警告:无法导入wsdl:port
详细信息:导入wsdl:port所依赖的wsdl:binding时出错。 XPath to wsdl:binding://wsdl:definitionf [@targetNamespace ='http://tempuri.org/']/wsdl:binding[@name='NetTcpEndpoint'] XPath到错误源://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 错误4自定义工具错误:无法为服务引用“DocumentService”生成代码。有关详细信息,请查看其他错误和警告消息。 c:\ TFS1 \ TestSolution - Test \ Test \ Test.Core \ Service References \ DocumentService \ Reference.svcmap 1 1 Test.Core
答案 0 :(得分:0)
添加Flag
属性后,您更改了枚举的存储方式,并使该类型的变量能够保存多个值。这个MSDN post解释了WCF如何处理这个问题的细节。除非你真的打算将Enum函数作为一个标志字段,否则我会摆脱它,因为它不需要使Enum复杂化。