Answered by:
Cannot add service reference

Question
-
I have a solution that has 2 console apps and one class library. The class library is my WCF service class and contract. One console is my host and the other is my client. Everything works okay if I copy the contract to the client, I have transfer of information. However, if I want to generate the proxy via a WSDL map I cannot add a service reference to my client. I have the host up and running ( I can see WSDL in my browser ) and when I right click on Add Reference in the client project the Service Reference option is disabled.
I thought it might have to do with the client being in the same solution so I made a separate solution for the client. It too runs okay with the contract copied manually, but once I try to add the Service Reference I have the same issue.
Is there some setting I am missing in my VS projects or something to disable this reference option?
I am using VS 2010 Release Candidate.
Thanks,
MWFriday, February 19, 2010 3:13 PM
Answers
-
Hi,
I had a similar problem when upgrading a solution to .Net 4. The 'Add Service Reference' item wasn't displayed on the projects right click menu, but I found that if I deleted the .suo and .sln.cache files (found in the solution directory) the issue was resolved.
- Marked as answer by Michael L. Wagner Tuesday, April 27, 2010 7:34 PM
Tuesday, April 20, 2010 9:40 PM
All replies
-
I had the same issue.
I solved it by rather than adding a service reference to the running host's URL, e.g. http://localhost:8881/MyService.svc instead don't run the host, choose Add Service Reference in your client, press Discover and you should see a reference to the WCF service library - it will look something like this Design_Time_Addresses/MyService/
Once you have added the service and the proxy has been generated, right click the proxy and choose 'configure service reference'. On the window that is displayed alter the Address to point at your host, that is, http://localhost:8881/MyService.svc
Hope that helps
RichieFriday, February 19, 2010 3:42 PM -
That sounds good, but when I right click the client project I do not have the option the add a service reference.
I think I am missing something in my project set-up for the client that activates that option.Friday, February 19, 2010 3:57 PM -
what is the target framework of your application?
- right click on the project in the solution explorer and select properties
- in the properties window's Application tab, check what is the value of Target Framework
I think the add service reference option is not available when you target 2.0 .net framework.
Amit SharmaFriday, February 19, 2010 9:33 PM -
Thanks for you reply Amir,
I originally targeted the 4.0 framework. After your reply I tried 2.0, 3.0, 3.5. The only one that was different was the 2.0. It offered a web service references option. All of the other framework only offer the plain "Reference" when you right click on Reference in the project.
Could this be a VS 2010 bug or am I missing some simple setting? It works fine in VS 2008.
MWSaturday, February 20, 2010 3:41 AM -
Are you trying to add a service reference with Visual Studio in Debug mode? I have only seen the observation you made about the option being greyed out in that case. If so, you can try running Visual Studio with CTRL+F5 when it will start without debug mode and this option should be visible. I am sure it is not a bug, I have been using the latets builds of VS and I haven't come across this. Thanks.
- PiyushSaturday, February 20, 2010 5:13 AM -
Yes. I am trying a demo put on by Michele Bustamante. She creates a host and service and starts it up. Then right clicks on the References tab in the client project to "Add a Service Reference". She is using VS 2005. I can perform this same process in VS 2008, but when I try it in VS 2010 the "Add Service Reference" is not even shown on the right click context menu ( or the Project menu ) for me to try it.
I do not believe it has anything to do with debug mode.
Client:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Dispatcher; namespace Client { // if not using runtime WSDL uncomment the contract info //[ServiceContract(Namespace="http://www.basicwcf/test/2010/01")] //public interface IWcfService //{ // [OperationContract] // string GetValue(string value); //} class Program { static void Main(string[] args) { IWcfService proxy = ChannelFactory<IWcfService>.CreateChannel(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/WcfService")); //localhost.WcfServiceClient proxy = new localhost.WcfServiceClient(); string s = proxy.GetValue("Hello from client"); Console.WriteLine(s); Console.ReadLine(); ; } } }
Host app.config:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <services> <service name="Service.WcfService" behaviorConfiguration="serviceBehavior"> <endpoint binding="basicHttpBinding" contract="Service.IWcfService" address ="WcfService" /> <endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex" /> <host> <baseAddresses> <add baseAddress="http://localhost:9000"/> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name="serviceBehavior"> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
Host:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Dispatcher; namespace Host { class Program { static void Main(string[] args) { using (ServiceHost host = new ServiceHost(typeof(WcfService.WcfService))) { host.AddServiceEndpoint(typeof(WcfService.IWcfService), new NetTcpBinding(), "net.tcp://localhost:9000/WcfService"); host.Open(); Console.ReadLine(); } } } }
Service:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; namespace WcfService { [ServiceContract(Namespace="http://www.basicwcf/test/2010/01")] public interface IWcfService { [OperationContract] string GetValue(string value); } public class WcfService : IWcfService { public string GetValue(string value) { return string.Format("You entered: {0} at {1}", value, DateTime.Now); } } }
- Edited by Michael L. Wagner Monday, February 22, 2010 10:50 PM
Monday, February 22, 2010 10:43 PM -
The only difference is I am using VS 2010 Release Candidate over VS 2008.Monday, February 22, 2010 10:47 PM
-
Update on my issue. I uninstalled VS 2010 and re-installed it. Same problem, no option to Add Service References.
I have noticed this anomaly: this occurs on my Vista machine. I also have VS 2010 Release Candidate installed on my XP machine and I can see the option on the menu(s). Anyone have an idea what I need to do on my Vista box to rectify this problem?Friday, February 26, 2010 5:53 PM -
Hi,
I had a similar problem when upgrading a solution to .Net 4. The 'Add Service Reference' item wasn't displayed on the projects right click menu, but I found that if I deleted the .suo and .sln.cache files (found in the solution directory) the issue was resolved.
- Marked as answer by Michael L. Wagner Tuesday, April 27, 2010 7:34 PM
Tuesday, April 20, 2010 9:40 PM -
I don't want to delete my solution files and have to rebuild them but it does work.
- Proposed as answer by Cosmo Skidoodle Wednesday, April 13, 2011 7:34 PM
Tuesday, April 27, 2010 7:34 PM -