Reputation: 44352
I have a console app and WCF service app in a solution. I'd like to call the WCF app from the console app. I added a service reference to the console app project and tried to reference the service but its namespace is not found. I'm using VS 2010. Any ideas what I'm doing wrong?
Upvotes: 0
Views: 6666
Reputation: 2977
Rececntly me too face the same problem. I did the following steps. 1) Open Reference.cs file 2) Your error may look like below error
Error 3 The type name 'ServiceReference1' does not exist in the type 'LongOperationClient.ServiceReference1.LongOperationClient'
Now in Reference.cs file ( which is autogenerated ) delete 'NamespaceOfProject.serviceReference1'
3) save and build It worked for me. Regards, Hemant
Upvotes: 0
Reputation: 161831
There's nothing special about console applications versus other application types when it comes to web service consumption.
See How to Consume a Web Service.
Upvotes: 0
Reputation: 11252
When you add a Service Reference, it's not the same as an Assembly Reference.
When you can add a Service Reference, you don't necessarily know the inner details of the service. In many cases it won't be your service, it will be another company's. A service reference just defines the contracts.
So you won't find your service using the namespaces or objects you declared on the service side. Rather, your client is actually defining client-side objects of its own based on the contracts. When you added the reference, you could choose the namespace to add it to.
In Visual Studio, click on your client project in the Solution Explorer and enable the "Show All Files" option. Then you should be able to navigate through the Service Reference and find the hidden files auto-generated the by the Add Service Reference wizard. You will see which namespace it's declared in by inspecting those files.
Upvotes: 3