我将所有服务合同和数据合同都放在一个单独的类库项目中,以便它可以被WCF项目和WPF项目引用:
在向WCF服务添加服务引用时,我确实将Visual Studio配置为重用所有引用的程序集,其中包括Contract项目:
生成过程失败,出现警告和错误:
Warning 1 The 'bindingConfiguration' attribute is invalid - The value 'BasicHttpBinding_IDataService' is invalid according to its datatype 'serviceBindingConfigurationType' - The Enumeration constraint failed. C:\..\App\App.Workflow\App.config 16 39 App.Workflow
Warning 2 The 'contract' attribute is invalid - The value 'IDataService' is invalid according to its datatype 'clientContractType' - The Enumeration constraint failed. C:\..\App\App.Workflow\App.config 16 80 App.Workflow
Error 3 Custom tool error: 'Reference.cs' : An assembly with the same simple name '.. Contract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side. C:\..\App\App.Workflow\Service References\DataServiceReference\Reference.svcmap 1 1 App.Workflow
生成将重用类库中定义的类型而不是重新生成类型的客户端类的正确方法是什么?
更新
我的配置文件:
工作流程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_IDataService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:54519/DataService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IDataService" contract="IDataService"
name="BasicHttpBinding_IDataService" />
</client>
</system.serviceModel>
</configuration>
答案 0 :(得分:0)
改变这个:
合同=&#34; IDataService&#34;名称=&#34; BasicHttpBinding_IDataService&#34;
到
contract =&#34; App.Contract.IDataService&#34; 名称=&#34; BasicHttpBinding_contract&#34 ;. -