本文介绍了安装封装:无法添加引用“System.Runtime”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用命令



 安装封装-PRERELEASE Autofac $安装Autofac的NuGet包在我的项目b $ b  

但它失败,出现错误

 安装封装:无法添加引用System.Runtime。请确保它在全局程序集缓存。 



我试着重新安装的.NET Framework 4.5.2(这是我的版本,项目的目标是),但得到了.NET框架4.5.2已经安装的消息。然而,搜索 C:\Windows\assembly\ System.Runtime.dll 没有找到任何精确匹配(虽然有 System.Runtime.ni.dll 的几个实例,(似乎表明),它们实际上是同一个程序集...)。



我能做些什么这个





更新:显然我很困惑的GAC的位置。 开导我,并在 c搜索从:\Windows\Microsoft.NET\assembly ,而不是我的的找到 System.Runtime.dll 。为什么不Visual Studio的?


解决方案

That is an excessively unhelpful error message. It not only doesn't describe the real problem, it also leads you drastically astray to find a workaround. An assembly reference for a .NET Framework assembly must never come from the GAC. The kind of failure modes when it does can be exceedingly nasty to diagnose. Reference assemblies must come from the C:\Program Files (x86)\Reference Assemblies directory.

Looking at the .nuspec file for the Autofac nuget package you are trying to install, it supports two distinct targets. One is for DNXCore version 4.0.10-beta-22816. Hopefully you are not using it, that project is changing rapidly.

The other is .NET Portable, profile 259. Which allows your project to target .NET 4.5.x, Store, Phone80 and Phone81. What the blunt error message is telling you is that it has trouble finding that profile. Use Windows Explorer to have a look-see, the profile is stored in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile259 directory. It has the required System.Runtime.dll reference assembly.

Well, surely it awol, I can't guess at the underlying reason.

They did make subtle mistakes in the .nuspec file. Do consider a more stable release of Autofac, you probably don't want to be a beta tester. And don't target 4.5.2, there is no point to that. It doesn't add anything interesting and forcing your user to update his .NET install is not very reasonable.

这篇关于安装封装:无法添加引用“System.Runtime”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:36