visual-studio <Subtype>Designer</Subtype> 在加载/卸载时由 Visual Studio 添加然后删除
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1573241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
<Subtype>Designer</Subtype> Added then removed by Visual Studio on load/unload
提问by Jeff Lundstrom
Anyone see this before? I have a large Visual Studio project that keeps adding [Subtype]Designer[/Subtype]to my .vcprojthen removing it on the next open and close of the project. There is only one class defined in StoredImageControl.cs. Anyone know how to shut this off as it is really messing up my revision control.
有人见过这个吗?我有一个大型 Visual Studio 项目,它不断添加[Subtype]Designer[/Subtype]到我的项目中,.vcproj然后在项目的下一次打开和关闭时将其删除。中只定义了一个类StoredImageControl.cs。任何人都知道如何关闭它,因为它真的弄乱了我的修订控制。
This is before:
这是之前:
<EmbeddedResource Include="StoredImageControl.resx">
<DependentUpon>StoredImageControl.cs</DependentUpon>
</EmbeddedResource>
This is after
这是之后
<EmbeddedResource Include="StoredImageControl.resx">
<DependentUpon>StoredImageControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
回答by Nathan Reed
This might be related to what files you have open in the saved solution state. I ran into this problem in VS2010 and found that if I close the solution while an .xml file was open in the editor, then on the subsequent re-open of the solution, the project containing that .xml file would get this <SubType>Designer</SubType>line added. If I close the solution without that file open, though, it does not try to add that line on the following re-open.
这可能与您在保存的解决方案状态下打开了哪些文件有关。我在 VS2010 中遇到了这个问题,发现如果在编辑器中打开 .xml 文件时关闭解决方案,然后在随后重新打开解决方案时,包含该 .xml 文件的项目将<SubType>Designer</SubType>添加此行。但是,如果我在没有打开该文件的情况下关闭解决方案,它不会尝试在以下重新打开时添加该行。
回答by JohnC
This has been an issue in at least 3 editions of Visual Studio, 2008, 2010 and now 2012. It is logged as a bug in Microsoft Connectbut the MS answer is "We have recorded your request but are not planning on fixing this at this time." Suggest you up vote the bug report as it is still active and might get a better response from MS with enough up votes.
这在至少 3 个版本的 Visual Studio、2008、2010 和现在的 2012 中一直是一个问题。它在 Microsoft Connect 中被记录为一个错误,但 MS 的回答是“我们已经记录了您的请求,但不打算在此修复此问题时间。” 建议您对错误报告进行投票,因为它仍然处于活动状态,并且可能会通过足够多的投票从 MS 获得更好的响应。
回答by JohnB
I am encountering the same problem in my ASP.NET web application's .csproj file:
我在 ASP.NET Web 应用程序的 .csproj 文件中遇到了同样的问题:
<ItemGroup>
<Content Include="site.master" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
Versus:
相对:
<ItemGroup>
<Content Include="site.master" />
<Content Include="Web.config" />
</ItemGroup>
My annoyance with this issue is due to revision control changes as well. The issue seems to be present in VS 2005/2008/2010. Have found the following question on Microsoft forums, but the answer is not clear.
我对这个问题的烦恼也是由于修订控制的变化。该问题似乎存在于 VS 2005/2008/2010 中。在微软论坛上找到了以下问题,但答案不清楚。
I hope that a VS setting causes it, in which case, I will like you know when I find out what that setting is.
我希望 VS 设置导致它,在这种情况下,当我发现该设置是什么时,我希望您知道。
回答by Mauro Gagna
Do you try to put the SubType as an attribute of the EmbeddedResource object?
您是否尝试将 SubType 作为 EmbeddedResource 对象的属性?
<EmbeddedResource Include="StoredImageControl.resx" SubType="Designer">
<DependentUpon>StoredImageControl.cs</DependentUpon>
</EmbeddedResource>
I saw a question like yours in the following link and he solved his problem with this:
我在以下链接中看到了一个像你这样的问题,他用这个解决了他的问题:
回答by Ivan
I found that <SubType>Designer</SubType>changes the behaviour for Web.config.
我发现这<SubType>Designer</SubType>改变了 Web.config 的行为。
We use WebDeploy to publish web service files.
我们使用 WebDeploy 来发布 Web 服务文件。
If SubType is setfor Web.config - it publishes this file correctly under the main directory where all content files go and .svc.
如果为 Web.config设置了SubType - 它会在所有内容文件和 .svc 所在的主目录下正确发布此文件。
If SubType is not set- it does above but also copies Web.config under bin\ subdirectory - which is very strange! In MsBuild log this happens during CollectFilesFrom_SourceItemsToCopyToOutputDirectory target.
如果未设置SubType - 它会在上面设置,但还会复制 bin\ 子目录下的 Web.config - 这很奇怪!在 MsBuild 日志中,这发生在 CollectFilesFrom_SourceItemsToCopyToOutputDirectory 目标期间。
回答by NidhinSPradeep
For me also this causes issues with version control when added new files to the project.
对我来说,这也会在向项目添加新文件时导致版本控制问题。
As a work around I did: undo pending changes to the project file and then manually added new files by right click -> add existing files to the project.
作为一种解决方法,我做了:撤消对项目文件的挂起更改,然后通过右键单击手动添加新文件 -> 将现有文件添加到项目中。
While doing this the tag < SubType >Designer< /SubType >doesn't come.
这样做时,标签< SubType >Designer< /SubType >不会出现。
Hope this will help someone. Hence posting this.
希望这会帮助某人。因此发布了这个。

