我正在WCF在本地运行两个程序
我的第一个程序在proxy.RegisterClient();
private void Form1_Load(object sender, EventArgs e)
{
InstanceContext context = new InstanceContext(this);
proxy = new Service1Client(context);
proxy.Open();
proxy.RegisterClient(); // Closes WCF Service
}
我在第一个程序中的app.config
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="duplexendpoint" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:9000/Service1/" binding="wsDualHttpBinding"
bindingConfiguration="duplexendpoint" contract="ServiceReference1.IService1"
name="duplexendpoint">
<identity>
<userPrincipalName value="ws02\khdz" />
</identity>
</endpoint>
</client>
</system.serviceModel>
我的第二个项目在
之后关闭WCF服务 ClinicService.Instance.SetConnectionString(ConfigurationSettings.AppSettings["connectionstring"]);
代码是
private void Form1_Load(object sender, EventArgs e)
{
InstanceContext context = new InstanceContext(this);
proxy = new Service1Client(context);
proxy.Open();
proxy.RegisterClient();
ClinicService.Instance.SetConnectionString(ConfigurationSettings.AppSettings["connectionstring"]);
}
和app.config是
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="duplexendpoint" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:9000/Service1/" binding="wsDualHttpBinding"
bindingConfiguration="duplexendpoint" contract="ServiceReference1.IService1"
name="duplexendpoint">
<identity>
<userPrincipalName value="ws02\khdz" />
</identity>
</endpoint>
</client>
</system.serviceModel>