VS2010打开我的类文件(的.cs)的设计模式 [英] VS2010 opens my class-file (.cs) in the designer mode

查看:853
本文介绍了VS2010打开我的类文件(的.cs)的设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个扩展的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?

推荐答案

如上所述在回答<一href="http://stackoverflow.com/questions/6256327/vs-2010-setting-non-gui-class-file-as-component">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)的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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