繁体   English   中英

我收到错误消息:“添加WebService时,“类型或名称空间名称'namespace2'在名称空间'namespace1'中不存在”

[英]I Got Error :“the type or namespace name 'namespace2' does not exist int the namespaces 'namespace1' ” when i add a WebService

我有一个网址为(非真实)的网站: www.example.com 在此站点中,我有一项服务(真实): http://www.example.com/services/smsService.asmx : http://www.example.com/services/smsService.asmx

我在visual-studio-2017有两个asp.net项目: project1project2

project1当我添加像http://www.example.com/services/smsService.asmx这样的webreference(添加服务参考...>高级...>添加Web参考...)时,一切正常,但在project2 webReference的名称空间无法识别。

project1我使用using NameSpace1.SmsWebService; 它可以工作,但是在project2我得到了这个错误!

两个项目几乎相同

首先删除在之前添加的服务引用,然后重建项目,然后添加新的服务引用在project2中配置Web参考引用时更改名称空间。 并确保在project2中未引用项目1。

经过一些googlingstack overflowing我发现我可以用其他方式添加服务。
我曾经以这种方式添加服务:
右键Add项目> Add > Service Reference... > Advanced... > Add Web Reference... ,然后编写URL和...
这样,某些文件(例如*.datasource无法下载(我不知道为什么!),因此该项目无法构建。
我通过以下方式更改了添加服务的方式:
右键单击“项目”>“ Add >“ Service Reference... ,然后填写地址并单击“ GO按钮!
令人惊讶的是,一切都很好! 除了某些className之外,最后需要一个SoapClient 意味着在我的代码oldClass更改为oldClassSoapClient
最后,此服务出现在解决方案的“ Service References ”中,而不是“ Web References
谢谢大家

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM