尝试绑定配置:System.ComponentModel.TypeConverter无法加载 [英] Trying to bind configuration: System.ComponentModel.TypeConverter can't be loaded
问题描述
我试图在控制台应用程序中使用ASP.NET Core配置(特别是Microsoft.Extensions.Configuration.Json)。当我调用 IConfigurationRoot.Bind()
时,会为程序集 System引发
。 FileNotFound
异常。 ComponentModel.TypeConverter
根据我的知识 这似乎是一个错误。 我的目标是.NET 4.5.2,引用了 是否有解决方法或其他步骤? 这也不起作用: 我的JSON代表字符串属性或者一个 我习惯于 I am trying to use ASP.NET Core configuration (specifically Microsoft.Extensions.Configuration.Json) in a console application. When I call To my knowledge This appears to be a bug. Or am I missing something? I'm targeting .NET 4.5.2, have referenced Is there a workaround or additional steps? This also does not work: It does not seem to matter whether my JSON represents string properties or a struct such as a I've been used to 这篇关于尝试绑定配置:System.ComponentModel.TypeConverter无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! TypeConverter
位于<$ c $系统程序集中的 System.ComponentModel.TypeConverter
程序集。 p>
System
以下NuGet软件包已安装:
< package id =Microsoft.Extensions.Configurationversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.Configuration.Abstractionsversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.Configuration.Binderversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.Configuration.FileExtensionsversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.Configuration.Jsonversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.FileProviders.Abstractionsversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.FileProviders.Physicalversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.FileSystemGlobbingversion =1.0.0targetFramework =net452/>
< package id =Microsoft.Extensions.Primitivesversion =1.0.0targetFramework =net452/>
ConfigurationBinder.Bind ,myconfig);
TimeSpan
。 TypeConverter
位于系统
中。我偷偷摸摸NuGet,发现确实有一个程序集, System.ComponentModel.TypeConverter
作为.NET核心的一部分。安装该软件包解决了我的问题。IConfigurationRoot.Bind()
it throws a FileNotFound
exception for the assembly System.ComponentModel.TypeConverter
.TypeConverter
is in the System.ComponentModel
namespaces in the System assembly, not the fictitious System.ComponentModel.TypeConverter
assembly.System
, and have the following NuGet packages installed:<package id="Microsoft.Extensions.Configuration" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration.Binder" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration.Json" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.FileProviders.Physical" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.FileSystemGlobbing" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Primitives" version="1.0.0" targetFramework="net452" />
ConfigurationBinder.Bind(config, myconfig);
TimeSpan
.TypeConverter
being in System
. I poked around NuGet and found there is indeed an assembly, System.ComponentModel.TypeConverter
as part of .NET Core. Installing that package fixed my problem.