Visual Studio generates "Settings1.Designer.vb" when I change a configuration setting
Asked Answered
Q

3

8

Sometimes (not always), when I edit a setting in the "My Project" page, when I add one or edit a value from there, I get an error : 'Settings is ambiguous between declaration in Modules '<project>.My.MySettingsProperty' and '<project>.My.MySettingsProperty'

Visual Studio creates a duplicate of My Project\Settings.Designer.vb, and registers both of them in the .vbproj file.

When this happens, I need to delete Settings.Designer.vb, remove the "1" in Settings1.Designer.vb, and remove the references to it in the vbproj file.

It also happens when I edit a Telerik ORM model (a designer.vb file copied to designer1.vb), with the added problem that in that case, the designer.vb file is empty afterwards.

Here is another description of the problem, by somebody else (who doesn't have an answer since 2009 except mine) : http://social.msdn.microsoft.com/Forums/en-AU/vbide/thread/29e7b9ff-5cdc-456b-9d2f-bc85145e8eaf

Can you think of a possible source, but more importantly, of a possible fix ?

I'm using Visual Studio 2008 Standard, and this problem did not happen a few months ago.

Thanks

Quintet answered 26/10, 2011 at 9:46 Comment(2)
Never heard of this problem before, it is very uncommon. It must be environmental, some kind of VS add-on that messes this up.Hive
Maybe ; I did have a problem (the settings were not read, and it created a "Visual Studio 2008" folder at the root of every solution I opened), but I reinstalled it, and now it works correctly. Maybe somebody else had that problem too ?Quintet
P
12

I suffered from this too, with Visual Studio 2008, when messing around too much with the application settings. The fix is described here.

In short, in the project file, there is a LastGenOutput XML element inside the XML element of the .settings file. If Visual Studio decides to add a 1 to the generated .Designer.cs file name, this will be persisted to the LastGenOutput XML element. As long as you don't revert this change in the project file, Visual Studio will continue to use the new .Designer.cs file whatever you try.


Update

A reproduction with Visual Studio 2008, 2010 and 2013 Update 1

  1. Create a new .settings file using the settings designer.
  2. In the designer, press "View Code", such that a companion file will be generated.
  3. Ensure the companion file is in the same directory as the other two files.
  4. Exclude all the three files from project.
  5. Show hidden files for the project.
  6. Unload the project.
  7. Reload the project.
  8. Include the three files. Notice that the designer file is now shown below the companion file.
  9. Change a setting in the designer and save. Notice how a second .Designer.cs file is generated.
Perineurium answered 1/3, 2013 at 15:15 Comment(2)
The project file is the file ending with .vbproj.Fawkes
For Visual Basic.vbproj projects, the file ending is .vb, for C# .csproj projects, the file ending is .cs. Otherwise, the issue is equivalent.Perineurium
Q
2

I had a similar problem using Visual Studio 2013: "ambiguous references" on inserting some new images on the general resources of the project. Suddenly it was not possible to compile after this innocent change.

The error shows a text like “Ambiguous reference between modules…” (and mention exactly the same module twice) and repeats for all the possible resources, images or texts. Also it was not possible to select new images for the controls from the list of resources and some windows couldn't be open.

This happened when unexpectedly the Visual Studio IDE duplicate the Resources.Designer.vb on MyProject folder (creating another file with a "1" added to the name: “Resources1.Designer.vb”).

To correct the error I edited the project file .vbproj by hand, erasing the reference to the second Resources.Designer (Resources1.Designer). I also erased the duplicated file from the MyProject folder.

After doing these two things (edition of the project file and deletion of the duplicated file) the project recovered and behaved normally.

I hope this could save some time to someone else on having the same error. Please make a back-up before deleting something!!! ;-)

Qoph answered 13/12, 2017 at 19:31 Comment(0)
P
1

Not sure if this is still an issue, but I just got the same problem and fixed it based on the suggestions here. Delete the duplicate file and manually edit the project file.

However, I found something that may be the root cause: I had 2 duplicate sections in my project file, with same elements for the settings file. So I deleted the duplicate ones. I'll see if the problem goes away now.

Pironi answered 29/7, 2022 at 20:15 Comment(1)
This seems a combination of "Me too.", "Thanks." and "I have no solution yet.". None of that is considered an answer here on StackOverflow. Please edit to make this according to How to Answer by providing what you found out. - Or delete it until you can contibute your appreciated insights. Have fun.Vagal

© 2022 - 2024 — McMap. All rights reserved.