Error displaying a WinForm in Design mode with a c

2020-07-14 10:29发布

I have a UserControl that is part of a Class library. I reference this project from my solution. This adds a control from the referenced project to my toolbox. I add tghe control to a form. Everything looks good, I compile all and run. Perfect...

But when I close the .frm with the control on it and re-open it, I get this error. The code continues to run.

It may have something to do with namespaces. The original namespace was simply "Design" and this was ambiguous and conflicting so i decided to rename it. I think that's when my problems began.

    To prevent possible data loss before loading the designer, the following errors must be resolved:   



    2 Errors   

  Ignore and Continue   
    Why am I seeing this page?   





   Could not find type 'Besi.Winforms.HtmlEditor.Editor'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.     




Instances of this error (1)  

1.   There is no stack trace or error line information available for this error.  


Help with this error  

Could not find an associated help topic for this error. Check Windows Forms Design-Time error list   


Forum posts about this error  

Search the MSDN Forums for posts related to this error   






   The variable 'Editor1' is either undeclared or was never assigned.     Go to code  





Instances of this error (1)  

1.   BesiAdmin frmOrder.Designer.vb Line:775 Column:1   Show Call Stack  

at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)  

Help with this error  

MSDN Help   


Forum posts about this error  

Search the MSDN Forums for posts related to this error   

8条回答
ゆ 、 Hurt°
2楼-- · 2020-07-14 10:30

I had this issue and came across this article in addition to others.

The sum of what I did was close VS, delete .SUO files and bin/obj directories - this resolved several, but not all of the designer errors. I also looked at my Designer.cs file and, in my case, found some variable declarations that were NOT pre-fixed with namespaces (i.e. private TabControl tabs_main; instead of private System.Windows.Forms.TabControl tabs_main;), so I edited the design file to include the full namespace and re-built. That solved this issue for me.

查看更多
贼婆χ
3楼-- · 2020-07-14 10:38

A few things to try:

  • Check your frmOrder.Designer.vb file for errors, or possibly using the wrong namespace. I know it probably says not to touch the file in a comment, but sometimes you have to. Just be careful.

  • Try cleaning/rebuilding your project if you can.

  • Remove and re-add the reference to your dll (and make sure you're referencing the right version with the right namespace). Maybe something is cached that shouldn't be.

  • Exit and restart VS.

查看更多
冷血范
4楼-- · 2020-07-14 10:43

In my case, the error message in the designer mentioned a particular DLL. I remove that DLL from "References" and then re-add it. Form designer works for a while, then, if I reopen the form (or control).

But the problem comes back, and I have to repeat.

查看更多
你好瞎i
5楼-- · 2020-07-14 10:43

In my case, it appeared that making the .resx file writable (it was originally readonly due to SSC) cleared up the problem. Interestingly, though, no changes were ultimately made to the resource file.

Cleaning, rebuilding, restarting, deleting the /bin and /obj folders did not seem to make any difference.

查看更多
放荡不羁爱自由
6楼-- · 2020-07-14 10:46

My problem was with System.Windows.Forms, so I removed it from references, compiled, then added it back in. The form now appears in it's designer. Problem solved.

查看更多
成全新的幸福
7楼-- · 2020-07-14 10:48

In my case (in VS 2005), I had an ImageList that was bound to Tab Pages of a Tab Control. In the Form1.Designer.cs I deleted the images from ImageList :

        ...
        // 
        // imageList
        // 
        this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
        resources.ApplyResources(this.imageList, "imageList");
        this.imageList.TransparentColor = System.Drawing.Color.Transparent;
        ...

and in the Form1.cs constructor I added the images for the ImageList and added the bindings (indexes):

    public Form1()
    {
        InitializeComponent();

        this.imageList.Images.Add(TemNyilv.Properties.Resources.plus);
        this.imageList.Images.Add(TemNyilv.Properties.Resources.pencil);
        this.imageList.Images.Add(TemNyilv.Properties.Resources.date_previous);
        this.imageList.Images.Add(TemNyilv.Properties.Resources.users_men_women);
        this.imageList.ImageSize = new System.Drawing.Size(32, 32);

        tabPage1.ImageIndex = 0;
        tabPage2.ImageIndex = 1;
        tabPage3.ImageIndex = 3;
        tabPage4.ImageIndex = 2;
        ...
    }

This is the second time I had this problem. (The second time I had the same problem when I tried to bind ImageList to a CustomImageComboBox)

I hope it helps others.

查看更多
登录 后发表回答