By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

VB.NET ignoring Option Explicit setting

P: n/a
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/VisualS...dbackID=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
Feb 27 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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\V isualBasic\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\ProjectTempla tes\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.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Jerad Rose" <no@spam.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>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/VisualS...dbackID=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


Feb 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.