Mono not reading values from my app.config?

让人想犯罪 __ 提交于 2020-01-02 04:08:10

问题


I have a standard app.config for a .NET 4.0 Console application created by Visual Studio 2010 when adding settings in the project Settings tab as described on MSDN here: Application Settiings.

If I update a setting value in the resulting MyAsseblyName.exe.config file in the same directory then run the exe I see this in code by going:

Properties.Settings.Default.MySetting;

However, if I do the same (with the same build and same files) running Mono 3.2.8 on Ubuntu 14.04 using the above line gives me the default value specified on project Settings tab instead of the updated value in the MyAsseblyName.exe.config file.

What do I have to do to make mono use my app.config like .NET does so values are read from file if they are there?

Workaround

For anyone else coming across this issue I was able to workaround it by moving my settings in my app.config into the old-school <appSettings> element from <userSettings> or <applicationSettings> created by the project designer. Then you can use:

var myValue = ConfigurationManager.AppSettings["MyKey"];

See http://msdn.microsoft.com/en-AU/library/system.configuration.configurationmanager.appsettings(v=vs.100).aspx

来源:https://stackoverflow.com/questions/23594269/mono-not-reading-values-from-my-app-config

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!