在运行时编译期间出现不明确的引用错误

时间:2022-08-18 20:17:36

I recently added some namespaces to my web.config file so that all of my aspx pages can reference various constants and enums without the need to add an import statement on each aspx page. Since adding this, we are now getting an error when trying to test an asmx web service. It appears that during the wsdl generation we get the following error:

我最近给我的web添加了一些名称空间。配置文件,使我的所有aspx页面都可以引用各种常量和枚举,而无需在每个aspx页面上添加导入语句。添加这个之后,我们现在在尝试测试asmx web服务时就会得到一个错误。似乎在wsdl生成期间,我们得到了以下错误:

CS0104: 'Message' is an ambiguous reference between 'System.Web.Services.Description.Message' and 'InsTech.ForeSight.Message'

CS0104:“Message”是“System.Web.Services.Description”之间的模糊引用。消息”和“InsTech.ForeSight.Message”

While researching this, I found out that DefaultWsdlHelpGenerator.asmx is called during the runtime compilation and there is a method in there that has the following signature:

在研究这个问题时,我发现了DefaultWsdlHelpGenerator。在运行时编译期间调用asmx,其中有一个方法具有以下签名:

void WriteSoapMessage(MessageBinding messageBinding, Message message, bool soap12) {

We have an object defined in our namespace called Message which is causing the ambiguous reference since this web service file is not fully qualifying their message.

我们在命名空间中定义了一个名为Message的对象,它导致了不明确的引用,因为这个web服务文件没有完全限定它们的消息。

How can I go about resolving this without removing the namespaces from the web.config? We have our web services in another folder in our virtual directory so I tried adding a web.config that did a clear on the namespaces but that did not appear to work.

如果不从web.config中移除名称空间,我该如何解决这个问题呢?我们将web服务放在虚拟目录中的另一个文件夹中,因此我尝试添加一个web。配置,它在名称空间上做了一个清晰的标记,但是似乎没有工作。

Any help would be appreciated. Thanks Kevin

如有任何帮助,我们将不胜感激。谢谢你凯文

1 个解决方案

#1


3  

You can use namespace aliases in your code and use that to differ between them:

您可以在代码中使用名称空间别名,并使用它们之间的差异:

using ourOwn=our.own.namespace;

And refer to your Message class as ourOwn.Message. That will avoid the collision.

并将消息类引用为ourow .Message。这将避免碰撞。

#1


3  

You can use namespace aliases in your code and use that to differ between them:

您可以在代码中使用名称空间别名,并使用它们之间的差异:

using ourOwn=our.own.namespace;

And refer to your Message class as ourOwn.Message. That will avoid the collision.

并将消息类引用为ourow .Message。这将避免碰撞。