WCF中枚举的DataContract [英] DataContract for enums in WCF

查看:89
本文介绍了WCF中枚举的DataContract的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个枚举,可通过.Net项目中的WCF服务使用.现在,我想添加另一个枚举,该枚举的指定方式与第一个枚举相同. 但是第二个没有在Reference.cs中注册,因此无法从使用WCF服务的项目中识别出来.

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,
 }

我试图添加名称和命名空间,但没有结果.我已经检查过,因此不再有对FirstEnum的引用,在编写SecondEnum时我会想念它. Thwy似乎是用相同的方式编写的.

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.

那么,为什么在Reference.cs类中无法识别DataContract?我想,如果我能弄清楚这一点,其余的将自行解决.

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.

感谢任何想法.

推荐答案

服务合同中的任何操作中是否引用了第二个枚举? WCF只会添加属于合同一部分的元数据类型.

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.

这篇关于WCF中枚举的DataContract的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆