Error CS1518: Expected class, delegate, enum, interface, or struct...

Problem

You receive this error when compiling your application:

Error CS1518: Expected class, delegate, enum, interface, or struct...

This error occurs when a record or a table control is deleted and one or more of the global attributes related to this control do not get commented out.  This error will only occur in pages where a record or a table control has been deleted.  If the control deleted is a record control, then one attribute may remain uncommented, while for a table control, there are usually two attributes that are uncommented.

Solution

Open the pages in Visual Studio .NET and comment out the appropriate declaratives in the last section of the class.

[System.Web.UI.ToolboxDataAttribute("<{0}:BranchNotesTableControl runat=server></{0}:BranchNotesTableControl>")]

[System.ComponentModel.DesignerAttribute("System.Web.UI.Design.ReadWriteControlDesigner, System.Design")]

The Visual Studio .NET error indicator under the last “}” bracket will dissapear.

You will have to manually comment out the one (or two) uncommented lines of code in all files where you deleted a table or a record control.

See Also

Part VII:  Troubleshooting Applications

Application Generation and Compilation Error Messages