爲MVC將中間件ASP.NET核心解決方案未能從程序集加載類型 - ASP.NET核心
System.TypeLoadException 未能加載類型「Microsoft.Extensions.DependencyInjection當我收到以下錯誤。從組件 'Microsoft.Extensions.DependencyInjection.Abstractions,版本= 1.0.0.0,文化=中性公鑰= adb9793829ddae60' Extensions.ServiceCollectionExtensions。
Line 26: public void ConfigureServices(IServiceCollection services)
Line 27: {
Line 28: services.AddMvc();
Line 29: services.AddSingleton(provider => Configuration);
Line 30: services.AddSingleton<IGreeter, Greeter>();
at Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services, Action<MvcOptions> setupAction)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services, Action<MvcOptions> setupAction)
at OdeToFood2.Startup.ConfigureServices(IServiceCollection services) in C:\Users\aindriu\documents\visual studio 2015\Projects\OdeToFood2\src\OdeToFood2\Startup.cs:line 28
System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(object target, Object[] arguments, Signature sig, bool constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.Invoke(object instance, IServiceCollection exportServices)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
我在project.json文件相關的
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Autofac.Extensions.DependencyInjection": "4.0.0-rc3-309"
},
有不同的版本在JSON文件之間的衝突?
這裏是我的解決方案 -
https://dl.dropboxusercontent.com/u/10629841/OdeToFood2.zip
你嘗試用1.0.0更換所有的RC {1,2,3} .NET核心的依賴? – MMK
我替換了兩個,但沒有更改「Microsoft.AspNet.Diagnostics」:「1.0.0」, 「Microsoft.AspNetCore.StaticFiles」:「1.0.0」, – Aindriu