Question

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?

Was it helpful?

Solution

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!

OTHER TIPS

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

Look at the proxy class that is generated by visual studio for your service and see what is the namespace and the class name

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top