我创建了一个添加了两个整数的简单WCF服务。服务主机完美启动。但在客户端,我得到以下编译错误Reference.cs
:从客户端访问WCF服务时出错
The type name 'ServiceReference1' does not exist in the type 'WcfServiceClient.ServiceReference1.WcfServiceClient'
客户端代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WcfServiceClient
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ServiceReference1.WcfServiceClient client = new ServiceReference1.WcfServiceClient("BasicHttpBinding_IWcfService");
int result = client.Add(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text));
Label1.Text = result.ToString();
}
}
}
更新参考 – Sajeetharan
@Sajeetharan更新了几次。它正在更新。仍然出现错误 – Mangrio
您提供的参考名称是什么? – Sajeetharan