Asp – Nonsensical Parsing Errors after Removing Code Behind from ASP.NET MVC Project

asp.net-mvcvisual-studio-2008

I've recently upgraded an ASP.NET MVC Project written with the Beta version of the framework to the use the full 1.0 version. Part of this process involved deleting all the unused code-behind files associated with the view pages.

However, since I've done this, whenever I open an .aspx or .ascx in Visual Studio, I get hundreds of parse errors in the VS error list that bear no relation to what's in the file. 'Syntax error', 'End of Statement Expected', 'Statement cannot appear outside method body', etc., all repeated tens of times, right up to 'Maximum number of errors has been exceeded'. None of the errors have any line or column numbers, and most of the views contain hardly any server-side code at all. This is more than just a mild annoyance because it means I lose Intellisense when editing a view and I can't see when any real errors are flagged up.

The solution builds, and every view is processed and renders fine at run-time, but the errors in Visual Studio remain.

I've searched online for solutions to this and can't find any, so I'm hoping someone can point me towards what I'm doing wrong. I'm thinking I may have to create a new 1.0 project from scratch and port the files across, however I'd rather not have to do this as it's a large project.

Thanks in advance

Best Answer

Idiot alert!

In my haste when editing the page directives to remove the references to the Code Behind files, I accidentally deleted the 'Language="C#"' directive from the some of the view pages. This is what was causing the parsing errors!

Turns out re-creating the whole project was a waste of time!

Just goes to show you need to check the small things first...