依赖于框架程序集“System.Runtime,Version=4.0.10.0,"在当前目标框架中无法解决 [英] Dependency on the framework assembly "System.Runtime, Version=4.0.10.0," which could not be resolved in the currently targeted framework

查看:31
本文介绍了依赖于框架程序集“System.Runtime,Version=4.0.10.0,"在当前目标框架中无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TFS 2013 - 构建:ASP.Net 4.5.1 网站我收到此错误:

TFS 2013 - Build: ASP.Net 4.5.1 website I get this error:

warning MSB3268: The primary reference "C:Builds2MyProjWeb1_MaininMyProj1.dll"
 could not be resolved because it has an indirect dependency on the framework assembly 
"System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which
 could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.1". To resolve this problem, either remove the reference 
"C:Builds2MyProjWeb1_MaininMyProj1.dll" or retarget your application to a framework 
version which contains "System.Runtime, Version=4.0.10.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a".

所有项目和站点最初都是使用 Unity 1.0.0.0 的 4.0.我将其升级到 4.5.2.此外,上述错误中的 MyProj1 引用了 Unity,我也将其升级到 3.5.1.

All projects and site was 4.0 initially using Unity 1.0.0.0. I upgraded it to 4.5.2. Also the MyProj1 in the error above is referencing Unity and I upgraded it to 3.5.1 as well.

阅读:https://unity.codeplex.com/workitem/12756构建服务器已经在解决方法中指出了更新的 4.5.2.

Read this: https://unity.codeplex.com/workitem/12756 The build server already have the updated 4.5.2 pointed in the workaround.

所以我降级到 4.5.1 但仍然出现错误.

So I downgraded to 4.5.1 but still getting the error.

  • 通过 Visual Studio 2013 在本地构建良好的解决方案.

  • Solution builds fine locally via Visual studio 2013.

在 TFS 中构建的独立类库项目很好,但是当 MyProj 被添加为对我网站的引用时,它就会失败.

The stand alone class libraries project build in TFS fine but when MyProj is added as a reference to my Website, that's when it fails.

有什么想法吗?

在升级时,除了 TragetFramework 设置之外,我是否需要对 web.config 进行任何更改?

Do I need any web.config changes other than TragetFramework settign while upgrading?

推荐答案

由于我的项目依赖于其他项目,我不得不将我的 Unity 升级到 3.5,这个错误再次出现.这次终于修好了.

I had to upgrade my Unity to 3.5 due to my project's dependency on some other project and this error came again. This time, finally got it fixed.

这个帮助了我:http:///devsilos.blogspot.com/2014/10/msb3268-while-targeting-aspnet-web-site.html

解决方案我复制了构建抱怨的所有文件:

Solution I copied all the files that build was complaining about from:

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2Facades

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2

这是上面链接的解释,以防将来因任何原因而关闭:

Here's the explanation from the link above in case it goes down for any reason in future:

更深入的检查揭示了以下有趣的事实:aspnet_compiler 出于某种原因没有考虑 .dll-s位于 4.5 程序集的 Facade 目录下 (C:Program文件 (x86)参考组件MicrosoftFramework.NETFrameworkv4.5Facades).它看起来仅在 C:Program Files (x86)Reference 下程序集MicrosoftFramework.NETFrameworkv4.5

A deeper inspection revealed the following interesting fact: aspnet_compiler for some reason does not take into account the .dll-s that reside under the Facade directory of 4.5 assemblies (C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5Facades). It looks only under C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5

结果整个事情都失败了,因为 System.Threading.Tasks和 System.Runtime .dll-s 位于 Facades 目录下,而不是在 v4.5 内.

As a result the whole thing failed since both System.Threading.Tasks and System.Runtime .dll-s were under the Facades directory and not inside the v4.5.

现在的解决方案:

  • 只需简单地将丢失的 .dll-s 从 Facade 复制到 v4.5目录.
  • 在 .sln 文件中将 TargetFrameworkMoniker 设置为 4.5.1.最正确语法如下: TargetFrameworkMoniker =.NETFramework,Version%3Dv4.5.1".

在这种情况下发生的事情是 aspnet_compiler 没有识别所需框架的确切版本并尝试尽可能使用 GAC.如果 4.5 是安装的最高版本在构建机器上我相信它应该可以工作.

What happens in this case is that the aspnet_compiler does not recognize the exact version of the required framework and tries to use the GAC wherever it can. If 4.5 is the highest version installed on the build machine I believe it should work.

这篇关于依赖于框架程序集“System.Runtime,Version=4.0.10.0,"在当前目标框架中无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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