未将对象引用设置为对象的实例

未将对象引用设置为对象的实例

本文介绍了Nuget - 未将对象引用设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 vs 2015 中遇到了 nuget 包管理器的问题.一些像 Unity 这样的软件包已经安装没有问题.某些软件包(如 EF)在安装时出现问题.一些像 Automapper 这样的包有同样的问题,但是当我安装这个包的另一个版本时,它安装得很好.

I have a problem with nuget package manager in vs 2015.Some packages like Unity has been installed with no problem.Some packages like EF had problems while installing.Some packages like Automapper had the same problem but when I installed another version of this package, It installed fine.

这里是输出:

System.NullReferenceException: Object reference not set to an instance of an object.


at NuGet.Protocol.Core.v3.GlobalPackagesFolderUtility.<AddPackageAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at NuGet.Protocol.Core.v3.DownloadResourceV3.<GetDownloadResourceResultAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.PackageDownloader.<GetDownloadResourceResultAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<ExecuteActionsAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<PerformActionAsync>d__3.MoveNext()
========== Finished ==========

推荐答案

使用 Visual Studio 2015 中使用的新协议(版本 3)nuget 的常见问题.它与多个 nuget 包一起使用,例如 Microsoft.Owin 3.0.1.要解决此问题,请访问:

It is a common problem with the use of the new protocol (version 3) nuget used in Visual Studio 2015. It is with multiple nuget packages, for example Microsoft.Owin 3.0.1.To fix this go to:

C:\Users\<your user name>\AppData\Roaming\NuGet

并编辑 XML 配置文件,注释掉协议 3:

And edit the XML configuration file, commenting the line of protocol 3:

<!-- add key = "nuget.org" value = "https://api.nuget.org/v3/index.json" protocolVersion = "3" /-->
<add key = "nuget.org" value = "https://www.nuget.org/api/v2/" />

版本 2 的维护设置.保存并重新启动 Visual Studio 2015.您现在应该可以毫无问题地恢复 nuget 包.

Maintenance settings for version 2. Save and restart visual studio 2015. You should now restore the nuget packages without problems.

这篇关于Nuget - 未将对象引用设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:14