Question

I've made an C# app with an GUI and some settings file for user settings. However, when I'm about to read the current values of the settings like MySettings.Default.SettingsName; it works perfectly for the first set of settings, say MyFirstSettings. For the second however, let's call it MySecondSettings, I get an error measure that says Ambiguity between My first Settings.Default and MySecondSettings.Default. I haven't been able to find any other way to access the settings but to use the .Default though.

Any tips would be really appreciated!

Axel

Was it helpful?

Solution

If you to have two settings files, it would generally work without any problems:

The following works (and compiles) for me perfectly:

Settings1.Default.Value1 = "11";
Settings1.Default.Save();

Settings2.Default.Value1 = "22";
Settings2.Default.Save();

So, the problem might occur if you created/copied the Settings2 file in some own and not really "fair" way outside of VisualStudio (for instance). (In that case both settings file might be refering still to the same "Settings1" class).


The way I created Settings2 file is to drag-n-drop in solution explored (with Ctrl key pressed (copying)) and renamed it from "Copy of Settings1" to just "Settings2".

Selecting "Add/New Items..." and selecting a new settings file works also greatly.

EDIT:

As the author of the question commented below:

In the DAQSettings "folder" I found two instances of the Designer, one named Day Settings1.Designer and one just named Settings.Designer.

... explains what was wrong in there, as there was a duplication (duplicate naming) for certain classes/elements, so the way to clear the problem is a "manual involving".

OTHER TIPS

In my case, I actually had a setting in the default settings file name Default. This caused an error that said

 Ambiguity between Settings.Default and Settings.Default

Changing this resolved the error.

Note:Yes, naming that setting 'Default' was a bad idea, however this is an extremely small program that does one thing, so if someone were to come behind me and look at this, they would probably know what it was for.

I had the error "Ambiguity between Settings.Default and Settings.Default" I went in the Settings.Designer.cs then removed an internal class that was made at the bottom named "Default".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top