Visual Studio将生成"Settings1.Designer.vb".当我更改配置设置时 [英] Visual Studio generates "Settings1.Designer.vb" when I change a configuration setting

查看:486
本文介绍了Visual Studio将生成"Settings1.Designer.vb".当我更改配置设置时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候(并非总是如此),当我在我的项目"页面中编辑设置时,当我在其中添加一个设置或编辑一个值时,出现错误:'Settings is ambiguous between declaration in Modules '<project>.My.MySettingsProperty' and '<project>.My.MySettingsProperty'

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创建My Project\Settings.Designer.vb的副本,并将它们都注册在.vbproj文件中.

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

发生这种情况时,我需要删除Settings.Designer.vb,在Settings1.Designer.vb中删除"1",然后在vbproj文件中删除对其的引用.

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.

当我编辑Telerik ORM模型(将designer.vb文件复制到designer1.vb)时,也会发生这种情况,但又增加了问题,在这种情况下,designer.vb文件随后为空.

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.

这是该问题的另一种描述,由其他人(自2009年以来我一直没有答案):

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 ?

我使用的是Visual Studio 2008 Standard,几个月前没有发生此问题.

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

谢谢

推荐答案

在使用Visual Studio 2008处理应用程序设置时,我也遭受了这种困扰. 此处.

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

简而言之,在项目文件中,.settings文件的XML元素内有一个LastGenOutput XML元素.如果Visual Studio决定在生成的.Designer.cs文件名中添加1,则该名称将保留在LastGenOutput XML元素中.只要您不还原项目文件中的此更改,Visual Studio就会继续尝试使用新的.Designer.cs文件.

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.

更新

使用Visual Studio 2008、2010和2013 Update 1进行复制

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

  1. 使用设置设计器创建一个新的.settings文件.
  2. 在设计器中,按查看代码",这样将生成一个伴随文件.
  3. 确保伴随文件与其他两个文件位于同一目录中.
  4. 从项目中排除所有这三个文件.
  5. 显示项目的隐藏文件.
  6. 卸载项目.
  7. 重新加载项目.
  8. 包括三个文件.请注意,设计器文件现在显示在伴随文件的下方.
  9. 在设计器中更改设置并保存.注意第二个.Designer.cs文件是如何生成的.

这篇关于Visual Studio将生成"Settings1.Designer.vb".当我更改配置设置时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆