I've created a class that extends DbConnection in a brand new project.
public class FakeDbConnection : DbConnection { ... }
In the Solution Explorer the class looks like this:
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>
Even if I remove the SubType
tag VS2010 immediately re-adds it. Very annoying.
How can I stop VS2010 from opening up my .cs file in designer mode and just open it up as a regular code file?
Start from a project If your program code is already in a Visual Studio project, open the project. To do so, you can double-click or tap on the . csproj file in Windows File Explorer, or choose Open a project in Visual Studio, browse to find the . csproj file, and select the file.
The designer file (. Designer. cs) is a code file automatically generated by your designer to hold the form's layout information that was created using the Visual Studio IDE. Once you add a new form in your application, VS will automatically generate the designer file for this form.
cs [Design] , which contains the drag&drop controls. If you are directly in the code behind (The file named Form1. cs , without "[Design]"), you can press Shift + F7 (or only F7 depending on the project type) instead to open it.
As described in an answer to this question you can do this:
[System.ComponentModel.DesignerCategory("Code")] class FakeDbConnection: DbConnection { ... }
Important: The attribute needs to be fully qualified otherwise VS2010 will ignore this.
Important (thanks to jmbpiano): The attribute only applies to the first class in the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With