I Got Error :"the type or namespace name 'namespace2' does not exist int the namespaces 'namespace1' " when i add a WebService

399 views Asked by At

I have a website with address (non-real) : www.example.com. in this site, i have a service (real) :http://www.example.com/services/smsService.asmx.

I have two asp.net projects in visual-studio-2017 : project1 and project2.

in project1 when i add a webreference(Add Service Reference... >Advanced...>Add Web Reference...) like http://www.example.com/services/smsService.asmx every thing is OK but in project2 the namespace of webReference doesn't recognize.

in project1 i use using NameSpace1.SmsWebService; and it works, but in project2 i get that error!

both projects are almost the same

2

There are 2 answers

0
mohammad mirshojaee On BEST ANSWER

After some googling and stack overflowing i found that i can add the service in other way.
i used to add the service in this way:
rightClick on Project > Add > Service Reference... > Advanced... > Add Web Reference... and then i write URL and ...
in this way, some files like *.datasource couldn't downloaded (i don't know why!) and thus the project failed to build.
I changed my way of add service with this:
rightClick on Project > Add > Service Reference... > and then i filled the Address and clicked GO Button!
Surprisingly everything was fine! except some classNames need a SoapClient at the end. means oldClass changed to oldClassSoapClient in my code!
At last, this service appeared in Service References of solution, not Web References
Thank you all buddies

0
Mustafa Radaideh On

first remove the service refernce that you added before , and rebuild the project then add new service reference Change the namespace while configuring the web reference reference in project2. and make sure that the project 1 is not referenced in project2.