user2950764 user2950764 - 1 year ago 178
C# Question

Ambiguity between settings in C#

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

it works perfectly for the first set of settings, say
. For the second however, let's call it
, 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

Any tips would be really appreciated!


Answer Source

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";

Settings2.Default.Value1 = "22";

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.


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".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download