DataContract for enums in WCF

ぃ、小莉子 提交于 2020-01-02 04:53:06

问题


I have a enum that I use via a WCF service in a .Net project. Now I want to add another enum, specified in the same way as the first. But the second one does not get registered in Reference.cs, and therefore is not recognized from the project consuming the WCF service.

I have tried to re-write everything as I read that there is an automatic count that is confused if one copy-pastes the enum members. I checked that the service reference is not re-using types in referenced assemblies.

 [DataContract]
public enum SecondEnum
{
    [EnumMember(Value = "WWW")]
    WWW = 0x0,
    [EnumMember]
    VVV= 0x1,
 }

I have tried to add Name and Namespace, without result. I have checked so there are no more references to the FirstEnum, that I would have missed when writing the SecondEnum. Thwy seem to have been written the same way.

So, why is a DataContract not recognized in the Reference.cs class? I guess that if I can figure this out, the rest will solve itself.

Thanks for any ideas.


回答1:


Is the second enumeration referenced in any operations on the service contract? WCF will only add to the metadata types which are part of the contract.



来源:https://stackoverflow.com/questions/6098800/datacontract-for-enums-in-wcf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!