I am performing the following steps.
-
Created a WCF service using WCF Service Library
-
Run and Test the WCF service by pressing F5 in the project (and it runs fine)
-
Create another project in the same solution in Visual Studio
- Add Service Reference to the WCF Service I created earlier in Step 1
However, the new project does not recognize the WCF Service I created in Step 1. How can I consume a WCF Service created in a different project?
The same service call works fine when it’s called from the same project. I get a red line on using HelloWorld2;
using HelloWorld2;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Helloworld2 client = new Helloworld2();
// Use the 'client' variable to call operations on the service.
// Name person = new Name();
// person.First = "Adam";
// person.Last = "Smith";
// Response.Write(person.First);
}
}
}
It was because I was missing the code where you add references
ServiceReference2.Helloworld2Client cc = new ServiceReference2.Helloworld2Client();
ServiceReference2.Name person = new ServiceReference2.Name();