Solving a Mystery About 'BC30205: End of statement expected'

A reader of my book ran into the strangest problem that had me going around in circles. He was working through one of the ASP.NET 3.5 examples in Visual Web Developer 2008 and was getting weird errors like these:

error BC30205: End of statement expected.
error BC30451: Name 'q' is not declared.
error BC30451: Name 'itm' is not declared

The reader had entered the VB code and markup exactly as required (using the single page model). Even dropping my working .aspx file into his site still caused the errors. Why?

After downloading the complete chapter code, the reader noticed the key difference - his site didn't have a Web.config file! Without a web.config file, the VB compiler just doesn't know what to do. Everything is wrong at that point and the IDE laces the code with squiggles.

Why didn't he have a web.config file? Well, if you choose the 'Empty Web Site' option in VWD 2008, that's what you get - an empty web site without a web.config.

What makes this strange is that my example code included a web.config file. My best guess is that one of those VWD wizards such as Configure Data Source (SqlDataSource) needs to store stuff in a web.config file.  If it doesn't find one, it silently adds it and goes about its business. Not all designers provide this service, so the existence of a web.config can be hit and miss - if you've used the Empty Web Site option.

Anyway, I've marked this as a bug (errata) in the book. The moral of the story is that your code can be perfect but unless the configuration tells the compiler what to expect, you'll get misleading error messages like 'error BC30205: End of statement expected. '

Ken

2 Comments

Comments have been disabled for this content.