问题描述
我已经创建了一个扩展的DbConnection 的一类全新的项目。
I've created a class that extends DbConnection in a brand new project.
public class FakeDbConnection : DbConnection { ... }
在Solution Explorer中的类看起来是这样的:
In the Solution Explorer the class looks like this:
当双击要在设计模式,这将无法正常工作打开它。开放的.csproj文件揭示了问题。
And when double-clicking it wants to open it in design mode which won't work. Opening up the .csproj-file reveals the problem
<ItemGroup>
<Compile Include="FakeADO\FakeDbConnection.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
即使我删除子类型
标签VS2010立即重新添加它。很烦人。
Even if I remove the SubType
tag VS2010 immediately re-adds it. Very annoying.
我怎么能阻止从VS2010在设计模式下打开了我的cs文件,只是打开它作为一个普通code文件?
How can I stop VS2010 from opening up my .cs file in designer mode and just open it up as a regular code file?
推荐答案
如上所述在回答this问题你可以这样做:
As described in an answer to this question you can do this:
[System.ComponentModel.DesignerCategory("Code")]
class FakeDbConnection: DbConnection { ... }
重要提示:的属性必须是的否则VS2010会忽略这一点。
Important: The attribute needs to be fully qualified otherwise VS2010 will ignore this.
这篇关于VS2010打开我的类文件(的.cs)的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!