简体   繁体   中英

Form showing as a class in Solution Explorer

I have a form in my project that is showing up as a class in Solution Explorer. This is causing a problem since I can't get to the designer. Any ideas on how to fix this?

You can fix the problem manually by editing your csproj file.

Open it in notepad and search for the filename of the class. You should see something like this...

<Compile Include="frmTest.cs" />

Add a subtype called 'Form' like this...

<Compile Include="frmTest.cs">
    <SubType>Form</SubType>
</Compile>

Reload the project. Visual Studio should now identify the file correctly.

删除与窗体相关的dll的引用,然后再次添加并构建项目

Try seeing if there are any hidden files by using the the 'Show All Files' button. Sounds like your project file might not have all of the files added to it.

One thing that has worked for me in the past is to just add another blank form to the project and that seemed to make the other form show up as a form. You can then delete the blank form.

I don't know if it will work for you, but it only takes a few moments to try it.

Chris

Simply select the form and press Shift+F7. You'll find your form.

Press F7 when in code editor to get to the designer. And restarting Visual Studio usually helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM