程序集引用无法解决-dependentAssembly问题? [英] Assembly reference cannot be resolved - dependentAssembly issue?

查看:41
本文介绍了程序集引用无法解决-dependentAssembly问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构建服务器(TFS/Visual Studio Online)上发生以下错误:

I have the following errors occurring on my build server (TFS/Visual Studio Online):

CA0055 : Could not load C:\a\Binaries\Api.dll. The following error was encountered while reading module 'System.Net.Http.Formatting': Assembly reference cannot be resolved: Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed.
CA0058 : The referenced assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' could not be found. This assembly is required for analysis and was referenced by: C:\a\Binaries\Api.dll, C:\a\Sources\MyLocation\packages\Microsoft.AspNet.WebApi.Client.5.1.1\lib\net45\System.Net.Http.Formatting.dll.

这是我的Api.dll项目中此程序集的 web.config dependentAssembly 条目:

Here is the web.config dependentAssembly entry in my Api.dll project for this assembly:

<dependentAssembly>
  <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>

已安装的Json.NET NuGet软件包的实际版本为6.0.1:

The actual version of the installed Json.NET NuGet package is 6.0.1:

当查看项目引用时,我的Newtonsoft.Json为6.0.0.0:

When looking in the project references, I have the Newtonsoft.Json as 6.0.0.0:

参考中 System.Net.Http.Formatting 的版本为5.1.0.0.

The version of System.Net.Http.Formatting in references is 5.1.0.0.

在构建定义中启用了NuGet还原,并且我的本地副本没有这些错误,仅在TFS中存在.

NuGet restore is enabled in the build definition and I do not have these errors on my local copy, only in TFS.

有人可以发现问题所在吗?

我认为这可能是由于 dependentAssembly 条目引起的,但我无法使其正常工作.

I think it might be due to the dependentAssembly entry but I cannot get it to work.

推荐答案

问题出乎意料.

解决方法是在项目文件的每个相关< PropertyGroup> 部分下包括以下行:

The fix was to include the following line in the project file under each relevant <PropertyGroup> section:

<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>

要编辑项目文件,请右键单击该项目,然后单击卸载项目.现在,右键单击已卸载的项目,然后选择 Edit MyProject.csproj

To edit the project file, right click on the project and click on Unload Project. Now right click on the unloaded project and choose Edit MyProject.csproj

这篇关于程序集引用无法解决-dependentAssembly问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆