visual-studio-2015 - 无法使以下项目可运行(未将对象引用设置为对象的实例。)

标签 visual-studio-2015 asp.net-core asp.net-core-mvc asp.net-core-1.0

当我在安装了 .NET Core 1.0 SDK 和工具(预览版 2)的 Visual Studio 2015(更新 3)中创建默认 Web 项目并在恢复本地源代码管理更改后重新启动 Visual Studio 时,我得到以下信息 编译错误 :

Failed to make the following project runnable: MyDefaultWebProject (.NETCoreApp,Version=v1.0) reason: Object reference not set to an instance of an object.



根据 Visual Studio,错误位于 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets在线 262

在这一行有以下代码:
<Dnx
  RuntimeExe="$(SDKToolingExe)"
  Condition="'$(_DesignTimeHostBuild)' != 'true'"
  ProjectFolder="$(MSBuildProjectDirectory)"
  Arguments="$(_BuildArguments)"
  />

我该如何解决这样的问题?

最佳答案

我设法找到的唯一可行的解​​决方案是运行 dotnet restore命令:

C:\Dev\*****>dotnet restore

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 2181 ms
Expanding 100% 9113 ms
log  : Restoring packages for C:\Dev\*****\project.json...
log  : Restoring packages for tool 'BundlerMinifier.Core' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.Extensions.SecretManager.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' in C:\Dev\*****\project.json...
log  : Writing lock file to disk. Path: C:\Dev\*****\project.lock.json
log  : C:\Dev\*****\project.json
log  : Restore completed in 13207ms.

之后Visual Studio中的编译再次成功。

关于visual-studio-2015 - 无法使以下项目可运行(未将对象引用设置为对象的实例。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38328677/

相关文章:

visual-studio - 有没有办法让 Microsoft Visual Studio 在编辑窗口中以不同的方式显示自动生成的文件?

c# - 将 IsWix 模板添加到 Visual Studio 2015

c# - IdentityServer4在asp.net core中注册UserService并从数据库中获取用户

c# - ASP.NET Core - 单例注入(inject)时存储库依赖项注入(inject)失败

c# - 从 React 前端使用 API POST 到 Entity Framework Controller 时始终出现 null 异常

c# - 如何在 Visual Studio 2015 中将 c# csproj 编译为 exe - 错误 CS0579

visual-studio - 诊断工具窗口不支持使用 'Script' 调试引擎进行调试

c# - ASP.NET Core OWIN 中间件

asp.net-core - 如何在 Windows 构建服务器上使用本地包进行 dotnet 构建

c# - 如何在 Asp.Net Core 中注册同一接口(interface)的多个实现?