C# 使用引用的WCF
我已经创建了一个windows服务,它的任务是在同一个项目中启动WCF服务。现在我在同一个解决方案中的项目中有一个windows客户端。我已成功地在客户端上添加了服务引用,但当我按如下所示在using中键入服务引用时,它无法识别。有人知道这是怎么回事吗?我已经试过很多次了。我正在使用visual Studio 2012。我曾在2010年成功使用WCF(并不是说这就是问题所在) 客户端代码C# 使用引用的WCF,c#,wcf,wcf-binding,C#,Wcf,Wcf Binding,我已经创建了一个windows服务,它的任务是在同一个项目中启动WCF服务。现在我在同一个解决方案中的项目中有一个windows客户端。我已成功地在客户端上添加了服务引用,但当我按如下所示在using中键入服务引用时,它无法识别。有人知道这是怎么回事吗?我已经试过很多次了。我正在使用visual Studio 2012。我曾在2010年成功使用WCF(并不是说这就是问题所在) 客户端代码 using System; using System.Collections.Generic; using
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Serv....... //************ The reference is not recognized
namespace Validstate_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
客户端App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/ValidStateService/Service2/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService2"
contract="ServiceReference2.IService2" name="BasicHttpBinding_IService2" />
</client>
</system.serviceModel>
</configuration>
服务应位于Validstate_客户端命名空间中。以下using语句应该有效:
using Validstate_Client.ServiceReference2
解决方案导航器中的一个按钮是“显示所有文件”。如果单击此按钮,则可以在客户端项目中展开服务引用并打开reference.cs文件,从中可以看到生成的代码所在的命名空间。