Question Design-Time Exception Prevents Form Being Designed

engr.ahayee

Member
Joined
Aug 10, 2021
Messages
16
Programming Experience
Beginner
Why i am getting this error

Error-1.png
it was running fine but now it is giving this error
 
The error message indicates that the designer doesn't recognise any class defined in that file as one that can be designed, i.e. a control of some sort, which includes a form. The most likely reason is that the inheritance has been removed for some reason. I was able to reproduce that error by commenting out the inheritance in the boilerplate code added in a new project, i.e. I changed this:
C#:
public partial class Form1 : Form
to this:
C#:
public partial class Form1// : Form
I suspect that you have deleted that part yourself but it's also possible that the system glitched and did it. Either way, make sure that you're inheriting the System.Windows.Forms.Form class. If you are and the issue persists, you might try adding a new form to the project and see whether that breaks too. If not, look for differences to correct. If you can't find a cause, just add a new form and copy the appropriate code across from the existing one.
 
Back
Top Bottom