can't access the added service reference
Solution 1
I found the solution HERE which as Hoakie mentioned below instructions worked for me and my reference.cs is generated properly now:
1) Right click on Service Reference
2) Select Configure Service Reference
3) Uncheck "Reuse types in referenced assemblies"
and Voila!
Solution 2
This is caused by having the same namespace
name as class name.
Change your namespace to a name that is not the same name as your class and this will compile
Solution 3
Look at the proxy class that is generated by visual studio for your service and see what is the namespace and the class name
Solution 4
Another commonly overlooked issue is that the service reference appends the root namespace of your project to the namespace you provide in the service configuration.
In other words, if the namespace of your service is ServiceReference1, the actual namespace that will be created will be [RootNameSpace].ServiceReference1. RootNameSpace is usually the name of your project, so in most cases you can fix it simply by appending your service reference with your [projectname.]. If the name of your project is MyProject, then the namespace will be MyProject.ServiceReference1
It is also fairly simple to open the csproj (assuming C# project) file in notepad and search for "RootNamespace" to find the root namespace for the project.
arash moeen
Updated on May 21, 2021Comments
-
arash moeen almost 3 years
I've added a service reference to my mvc4 web project and left it with the default namespace "ServiceReference1", but when I wanna use that namespace, visual studio can't find it, like it doesn't exist, the webservice is up and working fine. What exactly am I doing wrong?
-
arash moeen about 10 yearsThe class name is "BaseJob" with namespace "SmsPanel, the service reference namespace is "ServiceReference1"...
-
arash moeen about 10 yearsWhere exactly can I access this proxy class ?
-
arash moeen about 10 yearsI can't find any service model binding in my web.config file, though I'm not sure the structure in mvc 4 but shouldn't the endpoint be added to my webconfig file ???
-
Reza about 10 yearsThere is a ServiceReference folder in your solution and generated files are there
-
arash moeen about 10 yearsIf you're talking about the service reference folder in my solution then there's nothing there than my service references.
-
Reza about 10 years@arashmoeen is it a WEB Service or a WCF Service?
-
arash moeen about 10 yearsIt's a web service and I've been using it in my other projects, php and asp.net project which works perfectly but in mvc it's the first time I'm using it and it's not working.
-
Reza about 10 yearsSo There is a "Web References" folder and files are there, right click on the folder and choose "Open folder in explorer"
-
Reza about 10 yearsif you have added the reference via visual studio it will add necessary things in web.config by it self
-
arash moeen about 10 yearswell it didn't add anything in my webconfig and that's the problem.
-
arash moeen about 10 yearsSorry my bad It's a WCF service, so there's a service reference folder in my solution explorer not a web reference.
-
Reza about 10 yearsSo did you find the reference.cs ?
-
arash moeen about 10 yearsYea but it's empty inside, All I did was "right click on project" -> "Add service reference" -> "fill address with 87.107.121.54/post/send.asmx and clicked ok" but I can't use it to create an object. What am I doing wrong?
-
arash moeen about 10 yearsI followed this naveenbhat.in/2013/07/mvc-4-wcf-add-service-reference.html but it didn't help, still got an empty reference.cs
-
Manoj Attal over 9 yearsIt worked for me as well. But does anybody no, what is its significance and why it worked?
-
Leonidas almost 9 yearsHuh... lost half a working day on this, searched the entire file hierarchy for the problem and this resolved it! Thank you very much friend!
-
Chakri over 8 yearsAwesome... As it is not working as expected why did the respective developers marked it by default?!!! They just made so to get many developers waste their half a day :(
-
sohaiby over 6 yearsworked for me in VS 2015.Would love to know the reasoning of this solution
-
Marius Popa over 5 yearsThank you. It worked for me as well, but the same as the others, I am not really sure about the reason why it worked.
-
BunkerBilly almost 5 yearsThank you! so much time wasted!