[英]CS0234: The type or namespace name '<namespace2>' does not exist in the namespace '<namespace1>.' (are you missing an assembly reference?)
[英]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
项目: project1
和project2
。
在project1
当我添加像http://www.example.com/services/smsService.asmx
这样的webreference(添加服务参考...>高级...>添加Web参考...)时,一切正常,但在project2
webReference的名称空间无法识别。
在project1
我使用using NameSpace1.SmsWebService;
它可以工作,但是在project2
我得到了这个错误!
两个项目几乎相同
首先删除在之前添加的服务引用,然后重建项目,然后添加新的服务引用在project2中配置Web参考引用时更改名称空间。 并确保在project2中未引用项目1。
经过一些googling
和stack 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.