简体   繁体   中英

What is this C# form Error in Visual Studio?

I have not clue what this issue is, since i am new to C#. Please Help Me. I tried googling the solution and i pressed those buttons in the error but it lead me to nothing.

在此处输入图片说明

This is because; you might have copied and paste that windows forms code and it is complaining about Form1_Load. This error comes when windows forms application cannot create forms. So, my advice is create new windows applications and make sure Forms names are correct. It has to be the exact same, otherwise it doesnt load.

It can be fixed, but because you're new to visual studio I recommend deleting all the changes you made in the designer code or to make a new project and only copy sections of the code to the correct place in the already generated code. Don't just copy paste code. This is only the top layer, but when you build it, it also has to match with the underlying code.

You can click the Link WindowsFormsApplication1 Form1.Designer.cs Line:37 Column:1 and there you see the real error. Most of the time it is because you deleted a Method in your Form1.cs before you delete the Event in your designer. (just wrong delete order).

If you delete an eventhandler in your codebehind, you always must assure if the formdesigner has a binding statement to the deleted eventhandler and delete this binding.

So if you click the Link WindowsFormsApplication1 Form1.Designer.cs Line:37 Column:1

you should come to a line similar to

Form1.Load += Form1_Load;

If the Form1_Load-Method is missing, the designer cannot generate your form.

So try to delete this one single line, and (if no more errors occure) you have a fair chance to get the designer opened.

Then you can bind a new Form1_Load eventhandler in the form's property page.

Good luck.

Unfortunately the WinForms-Designer is so intolerable to such minor errors that developers seldom can consider the advice to make no changes to brittle designer code when they are expected to getting their work done.

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