【发布时间】:2015-11-26 07:45:49
【问题描述】:
刚刚在 Mac 上使用 Visual Studio Code 启动 ASP.NET 项目
我已经完成了所有常规步骤,以成功完成的dnu restore 命令结束。
然后我运行 dnx web 并得到一个正在运行的 localhost:5000 - 但是当我浏览到该地址时没有内容。
在终端窗口中,我可以看到下面的错误(很抱歉,我没有将其全部包含在内,因为它非常冗长)。
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
User profile is available. Using '/Users/deanchalk/.local/share/ASP.NET/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[1]
Executing action method firstmacaspnetapp.Controllers.HomeController.Index with arguments () - ModelState is Valid'
fail: Microsoft.AspNet.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: Unable to resolve service for type 'Microsoft.Dnx.Compilation.ILibraryExporter' while attempting to activate 'Microsoft.AspNet.Mvc.Razor.Compilation.RoslynCompilationService'.
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Dnx.Compilation.ILibraryExporter' while attempting to activate 'Microsoft.AspNet.Mvc.Razor.Compilation.RoslynCompilationService'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites (Microsoft.Extensions.DependencyInjection.ServiceProvider provider, ISet`1 callSiteChain, System.Reflection.ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) [0x00000] in <filename unknown>:0
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite (Microsoft.Extensions.DependencyInjection.ServiceProvider provider, ISet`1 callSiteChain) [0x00000] in <filename unknown>:0
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite (IService service, ISet`1 callSiteChain) [0x00000] in <filename unknown>:0
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite (System.Type serviceType, ISet`1 callSiteChain) [0x00000] in <filename unknown>:0
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites (Microsoft.Extensions.DependencyInjection.ServiceProvider provider, ISet`1 callSiteChain, System.Reflection.ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) [0x00000] in <filename unknown>:0
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite (Microsoft.Extensions.DependencyInjection.ServiceProvider provider, ISet`1 callSiteChain) [0x00000] in <filename unknown>:0
我用谷歌搜索了一下,找不到任何信息。
我的 project.json 看起来像这样:
{
"version": "1.0.0-*",
"userSecretsId": "aspnet5-firstmacaspnetapp-88915393-5f54-4e2d-9285-912b92370fb0",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "firstmacaspnetapp"
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.SQLite": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.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.Dnx.Runtime":"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"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [
"npm install",
"bower install",
"gulp clean",
"gulp min"
]
}
}
有人有什么想法吗?
【问题讨论】:
-
我在 Windows 上使用 Visual Studio 时遇到了同样的错误。在我的情况下,我不小心在 rc2 运行时使用所有 rc1 包运行我的项目。切换运行时后一切正常。也许你也有类似的问题。
标签: asp.net asp.net-mvc visual-studio visual-studio-code