c# - System.IO.FileLoadException 如果在设置文件中使用俄语字母
问题描述
我创建了一个使用配置文件中的一些设置的 net framework 4.8 控制台应用程序。我在发布配置中构建这个应用程序并在我的服务器上运行它。
问题是当我在设置文件的值中使用一些俄语字母时 - 应用程序无法以System.IO.FileLoadException. Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0
异常启动。当我从设置文件中删除所有俄语字母时,它工作得很好。
当我从 Visual Studio 运行此应用程序时,无论设置文件中使用什么字母,它都能正常工作。
设置文件的主要部分如下所示
<configSections>
<sectionGroup name="Settings">
<section name="TestSettings" type="Foo.Bar.TestSettingsSection, Foo" />
</<sectionGroup>
</configSections>
<Settings>
<TestSettings>VALUE</TestSettings>
</Settings>
所以,
<TestSettings>значение</TestSettings>
失败和<TestSettings>value</TestSettings>
工作。
从配置读取的东西看起来像这样(它只是一个代码示例,不适用于我的 TestSettings 示例)
public class TestSettingsSection : ConfigurationSection
{
[ConfigurationProperty("Sources")]
public AppSettingSectionElement Sources
{
get => this["Sources"] as AppSettingSectionElement;
set => this["Sources"] = value;
}
public IOptions<TestSettings> CreateOptionsFromConfig()
{
var settings = Sources.InnerText.Split(',')
.Select(x => x.Trim())
.ToArray();
return Options.Create(new TestSettings
{
Sources = settings
});
}
}
public class AppSettingSectionElement : ConfigurationElement
{
public string InnerText { get; private set; }
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
InnerText = reader.ReadElementContentAsString();
}
}
这对我来说真的很奇怪,我什至无法理解我可以提供哪些额外的信息。因此,我们将不胜感激为什么会发生这种情况的任何想法。
解决方案
推荐阅读
- jquery - 无法从 Angular 中的 JQuery on() 方法访问全局变量
- sql-server - 无法加载新的数据事实表 SSIS
- dart - 如何正确启用/禁用 Flutter 的 Button
- reactjs - 意外令牌:生产构建中的运算符 (>)
- jquery - 在不刷新页面的情况下加载 Laravel 刀片
- php - 使用 xampp 在 system32 中的 .htaccess 和主机 URL“我创建”的问题
- python - 熊猫将距离除以 timedelta
- javascript - 使用组织帐户以编程方式登录 google 以进行 cypress 端到端测试
- python-3.x - 为什么我的 Python 程序在实际安装时输出“模块未找到错误”没有名为 psycopg2 的模块?
- r - 在 R 中调整帕累托图上的第二个 y 轴