Problems with Designer Generated Code in VB 2005
-
I dragged and dropped a database table to my form. Then I wrote some code that is not in the designer generated code. It is a sub routine for one of my tab pages. Here is the code.
Private Sub tabpgSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabpgSettings.Click ' declare variables 'TODO: This line of code loads data into the 'DataSet1.tbl_hours' table. You can move, or remove it, as needed. ' use the try block in case of an error Try Me.Tbl_hoursTableAdapter.Fill(Me.DataSet1.tbl_hours) Catch err As Exception MessageBox.Show(err.Message) End Try ' fill the Mon - Sun combo boxes with the hours End Sub
As soon as I pasted this code into the class I went back to the form designer and the form would not come up and there were a bunch of errors instead. Here are the errors that showed up instead of the form. One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. Why does it mention this code below? The code is not on 2006, it is on line 2010.The designer cannot process the code at line 2006: Me.DataSet1.DataSetName = "DataSet1" The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. Hide Edit at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.CreateQuoteExpression(XmlElementData xmlElement) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.XmlElementData.get_CodeDomElement() at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.EndElement(String prefix, String name, String urn) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.Parse(XmlReader reader) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.ParseXml(String xmlStream, CodeStatementCollection statementCollection, String fileName, String methodName) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e) at System.CodeDom.CodeMemberMethod.get_Statements() at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at System.Comp
-
I dragged and dropped a database table to my form. Then I wrote some code that is not in the designer generated code. It is a sub routine for one of my tab pages. Here is the code.
Private Sub tabpgSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabpgSettings.Click ' declare variables 'TODO: This line of code loads data into the 'DataSet1.tbl_hours' table. You can move, or remove it, as needed. ' use the try block in case of an error Try Me.Tbl_hoursTableAdapter.Fill(Me.DataSet1.tbl_hours) Catch err As Exception MessageBox.Show(err.Message) End Try ' fill the Mon - Sun combo boxes with the hours End Sub
As soon as I pasted this code into the class I went back to the form designer and the form would not come up and there were a bunch of errors instead. Here are the errors that showed up instead of the form. One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. Why does it mention this code below? The code is not on 2006, it is on line 2010.The designer cannot process the code at line 2006: Me.DataSet1.DataSetName = "DataSet1" The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. Hide Edit at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.CreateQuoteExpression(XmlElementData xmlElement) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.XmlElementData.get_CodeDomElement() at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.EndElement(String prefix, String name, String urn) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.Parse(XmlReader reader) at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.ParseXml(String xmlStream, CodeStatementCollection statementCollection, String fileName, String methodName) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e) at System.CodeDom.CodeMemberMethod.get_Statements() at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at System.Comp
You said that you pasted that code into your project. Make sure that tabpgSettings's click event is attached to that sub.(form design window>tabpgSettings's properites>Events>) Make sure you didnt delete "End Class" or "Public Class Form1" Undo the changes you made to: "Friend WithEvents DataSet1 As LessonProgram.DataSet1 Friend WithEvents Tbl_hoursTableAdapter As LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter Me.DataSet1 = New LessonProgram.DataSet1 Me.Tbl_hoursTableAdapter = New LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter" once you fix the first error this one will go away as well. If that doesnt work I would press undo (Ctrl+z) about 300 times to find out what you deleted. Its not the best advice but it will work.
-
You said that you pasted that code into your project. Make sure that tabpgSettings's click event is attached to that sub.(form design window>tabpgSettings's properites>Events>) Make sure you didnt delete "End Class" or "Public Class Form1" Undo the changes you made to: "Friend WithEvents DataSet1 As LessonProgram.DataSet1 Friend WithEvents Tbl_hoursTableAdapter As LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter Me.DataSet1 = New LessonProgram.DataSet1 Me.Tbl_hoursTableAdapter = New LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter" once you fix the first error this one will go away as well. If that doesnt work I would press undo (Ctrl+z) about 300 times to find out what you deleted. Its not the best advice but it will work.
I checked and I did not delete any code at all. In fact, no matter what I do I get these errors. I don't get these errors if I do not drag and drop a database table to the form. Here is exactly what I am doing. 1) I drag and drop a data base table to the form from the Data Sources window which adds the TableAdapter etc to the form. 2) If I type any code -- OR -- hit the enter key so that I can type code after a comment -- OR -- put a ' before some code to make it a comment or type any code at all I get these errors. I even downloaded SP1 for Visual Basic Express 2005 and it did not fix the errors. Does anyone have any idea at all what is causing this error? Are there any known bugs with adding tableAdapters using Visual Basic Express 2005? Is there anyone else out there that is having this same problem?