[Mono-osx] ConfigurationErrorsException loading user settings (duplicate key)
Matt Emson
memsom at interalpha.co.uk
Wed Jan 21 10:19:07 EST 2009
d_v wrote:
How are you reading your settings? What does your config file look like?
So if you have this file saved as "app.config":
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MySettingKey" value="My setting value"/>
</appSettings>
</configuration>
I don't know how the Mono compiler handles config files, but if you do
the above in a C#project and then compile it, it'll get moved and
renamed to "YourExeName.exe.config".
If you then use something like:
class TestConfig
{
public static void Main()
{
string setting =
System.Configuration.ConfigurationManager.AppSettings["MySettingKey"];
System.Console.WriteLine(setting);
}
}
Does that fail? That's a pretty basic thing that should work, if it
doesn't.
If you are speaking about Web based stuff, surely it should be
"Web.config"? AFAIK this never gets moved or renamed.
M
> I experienced the same thing. Thanks for your solution!
>
> I have had mixed results:
> In two different test applications, with a web service reference, I seem to
> be OK with both user and application configuration settings when creating a
> new web service instance.
>
> But my main application will fail, with a web service reference, if I have
> mixed scopes when creating a new instance of the web service. It was still
> an error even when I removed all other configuration settings. But when I
> changed the last remaining web service reference scope to "User" as you
> suggested, it worked.
More information about the Mono-osx
mailing list