首页 新闻 会员 周边 捐助

在Mac下用k web运行ASP.NET 5程序遇到的问题

0
悬赏园豆:30 [已解决问题] 解决于 2015-01-21 12:34

project.json中是这么写的:

{
    "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta2",
    "Microsoft.AspNet.Hosting": "1.0.0-beta2",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta2",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta2",
    "Microsoft.Framework.CodeGeneration": "1.0.0-beta2",
    "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta2",
    "Microsoft.AspNet.Mvc": "6.0.0-*"
    },
    "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:8001",
    "gen": "Microsoft.Framework.CodeGeneration"
    },
    "frameworks": {
    "aspnet50": {}
    }
}

运行k web,出现如下的错误提示: 

Missing method Microsoft.Framework.DependencyInjection.ServiceCollectionExtensions::AddContextAccessor(IServiceCollection,IConfiguration) 
in assembly .kpm/packages/Microsoft.Framework.DependencyInjection/1.0.0-beta3-10747/lib/aspnet50/Microsoft.Framework.DependencyInjection.dll, referenced 
in assembly .kpm/packages/Microsoft.AspNet.Hosting/1.0.0-beta2/lib/aspnet50/Microsoft.AspNet.Hosting.dll

System.MissingMethodException: Method not found: 'Microsoft.Framework.DependencyInjection.ServiceCollectionExtensions.AddContextAccessor'.
  at Microsoft.AspNet.Hosting.HostingServices.Create (IServiceProvider fallbackServices, IConfiguration configuration) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, 
  System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

请问如何解决这个问题?

问题补充:

在project.json的dependencies中添加

"Microsoft.Framework.DependencyInjection": "1.0.0-beta2",
"Microsoft.Framework.DependencyInjection.Autofac": "1.0.0-beta3-10754"

之后,错误变成了:

System.DllNotFoundException: httpapi.dll
  at (wrapper managed-to-native) Microsoft.Net.Http.Server.UnsafeNclNativeMethods/HttpApi:HttpInitialize 
  (Microsoft.Net.Http.Server.UnsafeNclNativeMethods/HttpApi/HTTPAPI_VERSION,uint,void*)
  at Microsoft.Net.Http.Server.UnsafeNclNativeMethods+HttpApi.InitHttpApi 
  (UInt16 majorVersion, UInt16 minorVersion) [0x00000] in <filename unknown>:0 
  at Microsoft.Net.Http.Server.UnsafeNclNativeMethods+HttpApi..cctor () [0x00000] in <filename unknown>:0 

    --- End of inner exception stack trace ---
  at Microsoft.Net.Http.Server.WebListener..ctor (ILoggerFactory factory) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Server.WebListener.ServerFactory.Initialize (IConfiguration configuration) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Hosting.HostingEngine.InitalizeServerFactory (Microsoft.AspNet.Hosting.HostingContext context) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Hosting.HostingEngine.Start (Microsoft.AspNet.Hosting.HostingContext context) [0x00000] in <filename unknown>:0 
dudu的主页 dudu | 高人七级 | 园豆:30939
提问于:2015-01-20 14:31
< >
分享
最佳答案
0

针对这个问题写了一篇博客:为什么在Mac中无法用k web运行ASP.NET 5程序

dudu | 高人七级 |园豆:30939 | 2015-01-21 12:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册