WCF - 常见库枚举问题 - C#
我有一个公共库,其中包含通过 DLL 在 WCF 服务和客户端之间共享的枚举。是的,我知道更好的方法是从我的公共库中创建一个服务 - 这是稍后的事。
我对公共库进行了更改,向枚举添加了另一个字段。编译后,我更新了 WCF 服务和 Web 客户端中的 DLL。
最初,我收到错误:
确保必要的枚举值 存在并标有 EnumMemberAttribute 属性如果 类型具有 DataContractAttribute 属性。
通过从客户端上的服务引用配置中删除“重用引用程序集中的类型”检查,很快就解决了这个问题。
但是现在,我收到一个关于我添加的新枚举值的错误:
无效的枚举值 'TestDataReceived_OK_NoDataWritten' 无法反序列化为类型...
所以这让我相信有两个库版本,但我不确定如何解决这个问题。
我没有在我的服务界面中设置任何类型的 [DataContract] 区域。如果我需要,一些代码示例将会很有用。
谢谢。
I've got a common library that contains enums that are shared between a WCF Service and a client by means of the DLL. Yes, I know the better way of doing this is to create a service out of my common lib - that's for later.
I've made a change to my common lib, adding another field to the enum. After compiling, I've updated the DLL's in both the WCF service and my web client.
Initially, I was getting the error:
Ensure that the necessary enum values
are present and are marked with
EnumMemberAttribute attribute if the
type has DataContractAttribute
attribute.
This was quickly corrected by removing the check from the service reference configuration on the client, "Reuse types in referenced assemblies".
Now, however I am getting an error referring to the new enum value I added:
Invalid enum value
'TestDataReceived_OK_NoDataWritten'
cannot be deserialized into type...
So this leads me to believe that there are two library versions out there, but I'm not sure how to resolve this.
I haven't setup any sort of [DataContract] areas in my service interface. If I need to, some code sample would be useful.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回来看到这一点,我确实通过正确配置配置文件解决了这个问题。
Coming back to see this, I did resolve this by configuring the config files correctly.