Visual Studio 2010 Beta 2 – Option Strict should cause build error when building ASP.NET Web Site

When working with Visual Studio 2010 Beta 2, you can set the default options for Visual Basic in the Options dialog box, which is available by clicking Options on the Tools menu. In the Options dialog box, expand Projects and Solutions and then click VB Defaults. The Options dialog box, opened on the VB Defaults page, is shown here.


The problem is that the options specified, when turned on, they’re not enforced when building an ASP.NET Web Site; no warnings, no errors. They will be added to new VB projects though, but not ASP.NET Web Site projects (WSP).

You can also set the same option by using the compilation element in your web.config file.

<compilation debug="false" strict="true" explicit="true" targetFramework="4.0" />

However, this still doesn’t work; you need to add the following markup to your web.config file, in the configuration element:

        optionstrict+ /optionexplicit+"/>

This causes a build error if you write code like this:

Dim test1 ' Causes an Option Strict error
test2 = "" ' Causes an Option Explicit error