VB.NET ignoring Option Explicit setting

J

Jerad Rose

I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore
the project-level setting for Option Strict?

I have the setting turned on in web.config:

<compilation debug="true" strict="true" explicit="true"
urlLinePragmas="true"/>

And also in the preferences:

Tools > Options > Projects and Solutions > VB Defaults > Option Strict: On

And I still have to explicitly declare Option Strict On at the top of
*every* code page. I did happen upon this article:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102081

But it's over a year old, and I would think this was surely fixed by now.
Also, this article states that the issue only applies to code in the
App_Code folder. However, I am having this issue with all code, including
my code behind my ASPX pages, so maybe I'm not experiencing the same issue.

Thanks in advance for any clarification on this odd but glaring issue.

Jerad
 
J

Juan T. Llibre

re:
!>I believe this issue is specific to ASP.NET.

Actually, it's not an ASP.NET issue.
It's a VS.NET issue because the VS templates determine the options enforced.

re:
!> Why does VB.NET (2.0) ignore the project-level setting for Option Strict?

It's a bug.

re:
!> And I still have to explicitly declare Option Strict On at the top of *every* code page.

To allow you to set Option Strict as the default behavior, you need to modify the VS templates.

Follow these steps:

Locate WebApplication.vbproj, inside:
drive:\VSInstallDir\Common7\IDE\ProjectTemplates\VisualBasic\Web\1033\­WebApplicationProject.zip

Extract it, modify the Option Strict line so it's On, save the file
and add it back to the zip file, overwriting the original file.

Notice there's other files in the same zip file where the option must be set, too.

Also, do the same for any file in:
drive:\VStudioInstallDir\Common7\IDE\ProjectTemplates\VisualBasic\Web
which has Option Strict = Off

btw, if you want to change the Option Strict option for other types of projects
( Windows app, Windows Service, Web Service, etc. ), you'll need to do the same for *their*
templates.

For a web developer, doing the same for web service templates makes sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top