关于svcutil为DataContract生成的名称空间的问题 [英] Question regarding namespace generated by svcutil for DataContract

查看:89
本文介绍了关于svcutil为DataContract生成的名称空间的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我刚开始玩WCF(O'Reilly的WCF书就在我手上).
到目前为止,我已经明白了,但是现在我偶然发现了一些我无法解决的问题.

我使用的DataContract包含一个KeyValuePair数组,这些数组在另一个程序集中(My.Lib.MessageParams)中定义.
项目本身具有不同的名称空间(My.Wcf.Test1).

当我通过svcutil创建代理时,得到了一个代理类,该类可以按预期定义DataMembers.

问题来了,代理获得的名称空间与(my.lib.MessageParams)中定义了DataContract的名称空间相同.

我可以以某种方式进行调整吗?

我不想在此处使用相同的名称空间(My.Lib.MessageParams)
由于发生事件,我想在收到邮件时触发.

我尝试了以下方法:
[DataContract(Namespace ="http://My.Wcf.MessageParameters")]



现在这似乎可行(我什么都没做,我只运行了svcutil多次),但是现在名称空间变成了小写字母.
正如Toli指出的那样,应该用帕斯卡盒包装...
知道如何符合此约定吗?

任何帮助,感激不尽;)
最好的问候,并祝您有美好的一天
Andy

Hi all,
I just started to play with WCF (O''Reilly''s WCF book at my hands).
So far I get the point, but now I stumbled into something I can not work around.

The DataContract I use contains an Array of KeyValuePairs, which are defined in a different assembly (My.Lib.MessageParams).
The project itself has a different namespace (My.Wcf.Test1).

When I create the proxy via svcutil I get a proxy class that defines the DataMembers as expected.

Here comes the problem, the proxy gets the same namespace as the one where the DataContract is defined in (my.lib.MessageParams).

Can I somehow adjust this?

I do not want to have the same namespace here (My.Lib.MessageParams)
because of an event I want to fire when a message is receiced.

I tried the following:
[DataContract(Namespace="http://My.Wcf.MessageParameters")]



This now seems to work (I din''t change anything, I just ran svcutil multiple times), but the namespace is turned into lowercase now.
As Toli pointed out it should be pascal-cased...
Any idea how to fit this convention?

Any help is kindly appreciated ;)
best regards and have a good day
Andy

推荐答案

我遇到了这个问题,我在源代码中调用svcutil后更改了名称空间名称:-D
I''ve had this problem, I changed the namespace name after calling svcutil in the source code :-D


这篇关于关于svcutil为DataContract生成的名称空间的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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