c# - 无法使用 "reusing types from referenced assemblies"选项生成 WCF 客户端类

标签 c# wcf visual-studio-2013

我将所有服务契约和数据契约都放在一个单独的类库项目中,以便它可以被 WCF 项目和 WPF 项目引用: projects

在添加对 WCF 服务的服务引用时,我确实将 Visual Studio 配置为重用所有引用的程序集,其中包括 Contract 项目: reuse

生成过程失败并出现警告和错误: errors

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

生成将重用类库中定义的类型而不是重新生成的客户端类的正确方法是什么?


更新

我的配置文件: 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>

最佳答案

改变这个:

contract="IDataService"name="BasicHttpBinding_IDataService"

contract ="App.Contract.IDataService" name="BasicHttpBinding_contract". –

关于c# - 无法使用 "reusing types from referenced assemblies"选项生成 WCF 客户端类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29293181/

相关文章:

wcf - 如何将位置 header 设置为 WCF 4.0 REST 中另一个服务的 UriTemplate 没有魔术字符串?

C# 文件位置难题

c# - 在 Visual Studio 2013 中调试期间筛选对象列表

c# - 如何订购无序序列

c# - 带有时间戳的范围键。使用 DynamoDB 进行查询和分页

c# - 在代码隐藏中设置 Xamarin.Forms 绑定(bind) CommandParameter

WCF 负载测试

windows - 安装 Visual Studio Community 2013 时无法将当前用户添加到 Hyper-V 管理员组错误

在 Visual Studio 2013 中调试时出现 Javascript 错误

c# - Dapper:映射层次结构和单一不同的属性