使用 WCF 找不到构建和引用的程序集

Built and referenced assembly not found with WCF

背景

我有一个启用 WCF 的项目 MyService,它引用了项目 MyModel 中的一组模型并引用了 运行 服务 http://example.com/endpoint.svc。所有三个项目都在同一个解决方案中。

问题

当我在 MyService 项目中编辑服务引用设置时,出现以下错误:

Custom tool warning: The assembly 'Namespace.MyModel' could not be found. Ensure that the assembly is referenced. If the assembly is part of the current development project, ensure that the project has been built.

程序集已构建并被引用。

这会导致 WCF 生成额外的 类 与 MyModel.

中现有的冲突的问题

尝试过的解决方案

这个问题似乎与 this MSDN forum thread 中讨论的问题相似,但是建议的解决方案(相当于重新启动 Visual Studio 和服务)不起作用。

我还尝试删除并重新添加引用,另外还结合了 Visual Studio 重启。

TL;DR

如何解决 WCF 无法看到程序集的问题?


附加信息

服务引用设置

服务参考设置设置如下:

  • Client

    • Address: http://example.com/endpoint.svc
    • Access level for generated classes: Public
    • Allow generation of asynchronous operations: checked and Generate task-based operations
  • Data Type

    • Always generate message contracts: unchecked
    • Collection type: System.Array
    • Dictionary collection type: System.Collections.Generic.Dictionary
    • Reuse types in referenced assemblies: checked and Reuse types in all referenced assemblies

Visual Studio

我正在使用 Visual Studio 2013 Pro Update 4 (12.0.31101.00 Update 4)

项目目标

全部针对 x64

问题似乎出在 Visual Studio 在后台使用 svcutil 的 x86 版本,而不是项目内置的 x64。

手动 运行 svcutil 生成所需的结果:

svcutil ^
/reference:../bin/Namespace.MyModel.dll ^
/out:Reference.cs ^
http://example.com/endpoint.svc?wsdl ^
/namespace:"*,Namespace.MyService"