我在哪裏我實現的功能將從appsetting.json讀取值處理TypeLoadException而在啓動
對於這種ASP.NET的核心應用工作讀書AppSettings.json,我下面這個教程 - http://benjii.me/2016/04/new-configuration-appsettings-mvc6-web-config-gone/
從本教程中,我在下面way-
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
}
在這個特別的線下自動綁定所有的應用程序設置 - services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
,我得到以下exception-
類型「System.TypeLoadException」的異常出現在 Microsoft.Extensions.OptionsModel.dll但在用戶代碼中沒有處理
其他信息:未能加載類型 「Microsoft.Extensions.DependencyInjection。 ServiceCollectionExtensions' from assembly'Microsoft.Extensions.DependencyInjection.Abstractions, Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'。
Project.json
{
"dependencies": {
"Microsoft.AspNetCore.Diagnostics":"1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
"Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.0",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"net461": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"web.config",
"Views",
"Areas/**/Views",
"appsettings.json"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
我無法弄清楚什麼,我在這裏失蹤。有人可以指出我錯過了嗎?
我的環境是VS2015 Professional update3和Windows 7機器。
感謝&問候
維沙爾
顯示你的' project.json' – haim770
haim770 added project.json – Vishal26