2
votes

I've been working on a project for a while. Design view (the form) was available to me, but suddenly, I don't have it anymore. The .cs file is there with all the controls, but I have no idea how to regenerate the form view. Can you help please? I am quite new to this.

This has happened to me before. I did find a way to get it back. But I forgot how to do it. Oops.

edit----- like I said, im new to this. I'm getting in a right mess. Here's the code with the compiler

Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Wayne\AppData\Local\Temporary Projects\WindowsFormsApplication2\Program.cs 18 33 WL Lending Calculator

Im sure I've renamed something I shouldn't have

`using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms;

namespace WL_Lending_Calculator { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } `

im trying to get the code to display correctly here, with the code tag, but not having much luck

6
"The .cs file is there with all the controls" What does that mean? What happens when you attempt to view the form in the Designer? Does the form itself still appear in Solution Explorer?Dan J
does it says Ignore and continue?Rye
Winform. "The .cs file is there with all the controls" I mean the file with all the code for the form is there, but no design view.Wayne

6 Answers

2
votes

Is the designer showing an exception? Usually the exception shows what's wrong. If not, usually a rebuild of the entire solution fixes it. This only works if the controls are all built from the same solution.

2
votes

As erwin said, the exception is the root of your trouble.

The designer NEEDS access to a compiled version of the design mode of all the component inside the aspx. There are many possibilities, depending on where is WLLendingCalc :

  1. WLLendingCalc is in an uncompiled library : try rebuild all (or at least rebuild the library)
  2. WLLendingCalc is an ascx with bad html / XML : correct it
  3. your library for WLLendingCalc compiles, but has a faulty design mode
  4. your ascx registration for WLLendingCalc is wrong in the aspx or your library registration is wrong : check Register TagPrefix ; Register Assembly
  5. your registration for WLLendingCalc is in web.config and there is a syntax error in it
1
votes

This works for 2010 visual studio C#. I hope it works for you too.

Open the .cs file

Right click anywhere in the code area and click on "View Designer"

1
votes

I managed to resolve this in Visual Studio 2017 by modifying the project.csproj file to contain an extra property 'SubType'.

<Compile Include="forms\ParcelEditor.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="forms\ParcelEditor.Designer.cs">
  <DependentUpon>ParcelEditor.cs</DependentUpon>
</Compile>

Instead of how it was before:

<Compile Include="forms\ParcelEditor.cs"/>
<Compile Include="forms\ParcelEditor.Designer.cs">
  <DependentUpon>ParcelEditor.cs</DependentUpon>
</Compile>
0
votes

If you right-click the file and select Open With..., do you see an option for CSharp Form Editor? (In the Open With... dialog you can also set the form editor back to being the default for the applicable type.)

0
votes

In you app.config file at your project folder you must iclude this code

    <Compile Include="MyForm.Designer.vb">
      <DependentUpon>MyForm.vb</DependentUpon>
    </Compile>
    <Compile Include="MyForm.vb">
      <SubType>Form</SubType>
    </Compile>
<EmbeddedResource Include="MyForm.resx">
      <SubType>Designer</SubType>
      <DependentUpon>MyForm.vb</DependentUpon>
    </EmbeddedResource>