首页 > 解决方案 > 无法运行 ASP.NET Core 应用程序

问题描述

我试图运行 ASP.NET Core 应用程序

这是global.json

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-update2"
  }
}

我遇到错误还原包失败

这是输出

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Users\AA\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\dnx.exe "C:\Users\AA\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore "D:\MyProject\src\MyProject"
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16609
  GET https://api.nuget.org/v3/index.json
Restoring packages for D:\MyProject\src\MyProject\project.json
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.ApplicationInsights.AspNet'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Diagnostics'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.IISPlatformHandler'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc.TagHelpers'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Server.Kestrel'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.StaticFiles'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Tooling.Razor'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.CodeGenerators.Mvc'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.FileProviderExtensions'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.Json'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.UserSecrets'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Console'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Debug'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.VisualStudio.Web.BrowserLink.Loader'
Warning: FindPackagesById: Microsoft.ApplicationInsights.AspNet
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.ApplicationInsights.AspNet'
Warning: FindPackagesById: Microsoft.AspNet.Server.Kestrel
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.AspNet.Mvc.TagHelpers
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Server.Kestrel'
Warning: FindPackagesById: Microsoft.AspNet.Tooling.Razor
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Configuration.FileProviderExtensions
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Logging.Debug
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc.TagHelpers'
Warning: FindPackagesById: Microsoft.AspNet.StaticFiles
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Tooling.Razor'
Warning: FindPackagesById: Microsoft.Extensions.Logging
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.StaticFiles'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Debug'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.FileProviderExtensions'
Warning: FindPackagesById: Microsoft.VisualStudio.Web.BrowserLink.Loader
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.CodeGenerators.Mvc
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.VisualStudio.Web.BrowserLink.Loader'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.CodeGenerators.Mvc'
Warning: FindPackagesById: Microsoft.Extensions.Configuration.Json
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Logging.Console
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.AspNet.Diagnostics
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Configuration.UserSecrets
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.AspNet.IISPlatformHandler
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.Json'
Warning: FindPackagesById: Microsoft.AspNet.Mvc
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.IISPlatformHandler'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Diagnostics'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.UserSecrets'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Console'
Warning: FindPackagesById: Microsoft.ApplicationInsights.AspNet
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.ApplicationInsights.AspNet'
Warning: FindPackagesById: Microsoft.AspNet.Server.Kestrel
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Server.Kestrel'
Warning: FindPackagesById: Microsoft.AspNet.Mvc.TagHelpers
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc.TagHelpers'
Warning: FindPackagesById: Microsoft.AspNet.StaticFiles
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.StaticFiles'
Warning: FindPackagesById: Microsoft.AspNet.Tooling.Razor
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Tooling.Razor'
Warning: FindPackagesById: Microsoft.VisualStudio.Web.BrowserLink.Loader
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Logging.Debug
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Logging
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Configuration.FileProviderExtensions
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.CodeGenerators.Mvc
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.FileProviderExtensions'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.VisualStudio.Web.BrowserLink.Loader'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Debug'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.CodeGenerators.Mvc'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging'
Warning: FindPackagesById: Microsoft.AspNet.IISPlatformHandler
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.IISPlatformHandler'
Warning: FindPackagesById: Microsoft.AspNet.Diagnostics
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Diagnostics'
Warning: FindPackagesById: Microsoft.Extensions.Logging.Console
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Configuration.Json
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.Extensions.Configuration.UserSecrets
  An error occurred while sending the request.
Warning: FindPackagesById: Microsoft.AspNet.Mvc
  An error occurred while sending the request.
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Logging.Console'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.Json'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.AspNet.Mvc'
  GET https://api.nuget.org/v3/index.jsonFindPackagesById()?id='Microsoft.Extensions.Configuration.UserSecrets'
Error: FindPackagesById: Microsoft.AspNet.Mvc.TagHelpers
  An error occurred while sending the request.
Error: FindPackagesById: Microsoft.ApplicationInsights.AspNet
  An error occurred while sending the request.
----------
Error: FindPackagesById: Microsoft.AspNet.Tooling.Razor
  An error occurred while sending the request.
Error: FindPackagesById: Microsoft.AspNet.Server.Kestrel
  An error occurred while sending the request.
Error: FindPackagesById: Microsoft.AspNet.StaticFiles
  An error occurred while sending the request.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   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 Microsoft.Dnx.Tooling.Restore.NuGet.HttpSource.<GetAsync>d__11.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 Microsoft.Dnx.Tooling.Restore.NuGet.NuGetv2Feed.<FindPackagesByIdAsyncCore>d__25.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 Microsoft.Dnx.Tooling.RemoteWalkProvider.<FindLibrary>d__6.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibrary>d__9.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryByVersion>d__8.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryMatch>d__6.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 Microsoft.Dnx.Tooling.RestoreOperations.<FindLibraryEntry>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 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>d__2.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 Microsoft.Dnx.Tooling.RestoreOperations.<CreateGraphNode>d__2.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 Microsoft.Dnx.Tooling.RestoreCommand.<CreateGraphNode>d__71.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 Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__69.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 Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass68_0.<<Execute>b__2>d.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 Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__68.MoveNext()
----------
Restore failed
An error occurred while sending the request.
NuGet Config files used:
    C:\ProgramData\NuGet\Config\Microsoft.VisualStudio.Offline.config
    C:\Users\AA\AppData\Roaming\NuGet\nuget.config
Feeds used:
    https://api.nuget.org/v3/index.json
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

这是project.json

{
  "version": "1.0.0-*",
  "userSecretsId": "aspnetcore-MyProject-3db060cf-000d-481d-b013-6fcaf0c10504",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx46": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts":{
    "prepublish": [
      "npm install",
      "bower install",
      "gulp clean",
      "gulp min"

    ]
  }
}

我在 .dnx 中安装了 dnx 1.0.0-rc1-update2,在 dotnet/sdk 中安装了 sdk 1.0.0-preview-1-003177

我删除了 dnxcore5.0 并更改了 project.json 中的框架,如下所示:

"frameworks": {
    "dnx46": { }
  }

并将 global.json 中的 SDK 更改为如下:

"sdk": {
    "version": "1.0.0-preview2-1-003177"
  }

因为我搜索了 1.0.0-rc1-update2 并没有找到

之后包恢复成功

但是当我尝试运行时,我遇到了这个错误

Unable to start process D:\MyProject\artifacts\bin\MyProject\bin\Debug\dnx46\win-x64\MyProject.exe
request failed with status code 500 Internal server error.
the full response has been written to C:\Users\AA\AppData\Local\Temp\HttpFailure_06_00_18.html

重新启动 Visual Studio 后出现此错误:

An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Extensions.DependencyInjection.Abstractions.dll

Additional information: No service for type 'Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment' has been registered.

标签: asp.net-core

解决方案


推荐阅读