System.IO.FileLoadException if using russian-letters in settings file

74 Views Asked by At

I've created a net framework 4.8 console application that uses some settings from the config file. I'm building this application in release configuration and running it on my server.

The problem is when i'm using some russian letters in values of the settings file - the app is failing to start with the System.IO.FileLoadException. Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0 exception. When i remove all the russian letters from settings file it works perfectly.

When i'm running this app from Visual studio it works, no matter what letters were used in settings file.

The main section of settings file looks like this

<configSections>
        <sectionGroup name="Settings">
            <section name="TestSettings" type="Foo.Bar.TestSettingsSection, Foo" />
        </<sectionGroup>
</configSections>
<Settings>
       <TestSettings>VALUE</TestSettings>
</Settings>

So, the <TestSettings>значение</TestSettings> fails and <TestSettings>value</TestSettings> works.

Thing that reads from config looks like this (it's just an example of code, won't work with my TestSettings example)

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();
        }
    }

It's really strange for me, i can't even understand what additional info i can provide. So, any ideas why this could happen will be appreciated.

0

There are 0 best solutions below