Friday, March 16, 2012

Option Strict and aspnet 2.0

I fully expected the lack of a way to set Option Strict globally to be fixed
in SP1. I can't seem to figure out if it has been fixed or not. It still
seems we have to add the declaration at the top of each and every single
code module. Am I missing something here?

--
-C. Moya
www.cmoya.comTo set Option Strict

1. With your VB Web project open, click "Tools", then "Options".
2. Make sure the "Show all settings" box is selected.
3. Go to "Projects and Solutions", and scroll down to "VB defaults".

You'll see the "Default Project Settings" and the "Option Strict" dropdown,
with "On" and "Off" choices.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message news:eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem
>to figure out if it has been fixed or not. It still seems we have to add the declaration at the top
>of each and every single code module. Am I missing something here?
>
--
-C. Moya
www.cmoya.com
>


Did you try this answer before offering it? My settings are already set to
this. I then created a new class in my web project (thinking it's only
applied to new files added) and was able to add
Dim i As Integer = "some text"
with no problem.

That's bad.

--
-C. Moya
www.cmoya.com
"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
news:%233mY9HrOHHA.2468@dotnet.itags.org.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

To set Option Strict
>
1. With your VB Web project open, click "Tools", then "Options".
2. Make sure the "Show all settings" box is selected.
3. Go to "Projects and Solutions", and scroll down to "VB defaults".
>
You'll see the "Default Project Settings" and the "Option Strict"
dropdown,
with "On" and "Off" choices.
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message
news:eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>>I fully expected the lack of a way to set Option Strict globally to be
>>fixed in SP1. I can't seem
>>to figure out if it has been fixed or not. It still seems we have to add
>>the declaration at the top
>>of each and every single code module. Am I missing something here?
>>
>--
>-C. Moya
>www.cmoya.com
>>


>
>
>


I havent used VB.Net in a while, I only use C# nowadays, but I seem to
remember that if you want to set option strict globally you need to
open visual studio to the start page, with no project loaded and change
the option strict setting then. all new projects from then on will be
option strict by default.

worth a try, but as I said, I haven't used VB for a while

C. Moya wrote:

Quote:

Originally Posted by

I fully expected the lack of a way to set Option Strict globally to be fixed
in SP1. I can't seem to figure out if it has been fixed or not. It still
seems we have to add the declaration at the top of each and every single
code module. Am I missing something here?
>
--
-C. Moya
www.cmoya.com


Not sure as not yet for real under 2.0 but I remember to have seen this is
now in the web.config file i.e. it could be perhaps different dpeending on
weteherr you are prcompiling the site (in whihc case the project level
property could aply) or on the fly (in which case the web.config option
could be used).

"C. Moya" <cmm@dotnet.itags.org.nospam.coma crit dans le message de news:
eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>I fully expected the lack of a way to set Option Strict globally to be
>fixed in SP1. I can't seem to figure out if it has been fixed or not. It
>still seems we have to add the declaration at the top of each and every
>single code module. Am I missing something here?
>
--
-C. Moya
www.cmoya.com
>


I have Option Strict On in Tools|Options->VB Defaults.
And also strict="true" in web.config.
It doesn't seem to matter.

It's also not in the list of bug fixes for SP1 (which is a fairly small list
considering the ludicrous amount of time that we've been waiting). But I
find it hard to believe that this hasn't been addressed... I'm hoping I'm
just overlooking something.

--
-C. Moya
www.cmoya.com
"Patrice" <http://www.chez.com/scribe/wrote in message
news:uV5kjtvOHHA.3552@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Not sure as not yet for real under 2.0 but I remember to have seen this is
now in the web.config file i.e. it could be perhaps different dpeending on
weteherr you are prcompiling the site (in whihc case the project level
property could aply) or on the fly (in which case the web.config option
could be used).
>
>
"C. Moya" <cmm@dotnet.itags.org.nospam.coma crit dans le message de news:
eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>>I fully expected the lack of a way to set Option Strict globally to be
>>fixed in SP1. I can't seem to figure out if it has been fixed or not. It
>>still seems we have to add the declaration at the top of each and every
>>single code module. Am I missing something here?
>>
>--
>-C. Moya
>www.cmoya.com
>>


>
>


re:

Quote:

Originally Posted by

That's bad.


It would only be bad if you couldn't modify the VS templates.

To change the default value of Option Strict, follow these steps:

Locate WebApplication.vbproj, inside:
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\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 thre'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

I agree that the IDE is buggy regarding the setting of this option,
but there's a viable workaround, as detailed in this post.

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

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message news:%23zytZMsOHHA.1248@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Did you try this answer before offering it? My settings are already set to this. I then created a
new class in my web project (thinking it's only applied to new files added) and was able to add
Dim i As Integer = "some text"
with no problem.
>
That's bad.
>
--
-C. Moya
www.cmoya.com
"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
news:%233mY9HrOHHA.2468@dotnet.itags.org.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

>To set Option Strict
>>
>1. With your VB Web project open, click "Tools", then "Options".
>2. Make sure the "Show all settings" box is selected.
>3. Go to "Projects and Solutions", and scroll down to "VB defaults".
>>
>You'll see the "Default Project Settings" and the "Option Strict" dropdown,
>with "On" and "Off" choices.
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en espaol : http://asp.net.do/foros/
>===================================
>"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message news:eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>>>I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem
>>>to figure out if it has been fixed or not. It still seems we have to add the declaration at the
>>>top
>>>of each and every single code module. Am I missing something here?
>>>
>>--
>>-C. Moya
>>www.cmoya.com
>>>


>>
>>
>>


>
>


I will try this workaround... though it seems kludgy. Regarding other types
of projects: no need... as Windows Forms projects respect the Option Strict
settings you specify. It's only ASP.NET 2.0 projects that brainnumbingly do
not.

Thanks for the tip.

--
-C. Moya
www.cmoya.com
"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
news:uTHk5pxOHHA.2140@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>That's bad.


>
It would only be bad if you couldn't modify the VS templates.
>
To change the default value of Option Strict, follow these steps:
>
Locate WebApplication.vbproj, inside:
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\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 thre'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
>
I agree that the IDE is buggy regarding the setting of this option,
but there's a viable workaround, as detailed in this post.
>
btw, if you want to change the Option Strict option for other types of
projects
( Windows app, Windows Service, etc. ), you'll need to do the same for
*their* templates.
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message
news:%23zytZMsOHHA.1248@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Did you try this answer before offering it? My settings are already set
>to this. I then created a
>new class in my web project (thinking it's only applied to new files
>added) and was able to add
>Dim i As Integer = "some text"
>with no problem.
>>
>That's bad.
>>
>--
>-C. Moya
>www.cmoya.com
>"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
>news:%233mY9HrOHHA.2468@dotnet.itags.org.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

>>To set Option Strict
>>>
>>1. With your VB Web project open, click "Tools", then "Options".
>>2. Make sure the "Show all settings" box is selected.
>>3. Go to "Projects and Solutions", and scroll down to "VB defaults".
>>>
>>You'll see the "Default Project Settings" and the "Option Strict"
>>dropdown,
>>with "On" and "Off" choices.
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espaol : http://asp.net.do/foros/
>>===================================
>>"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message
>>news:eDEH86qOHHA.4712@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...
>>>>I fully expected the lack of a way to set Option Strict globally to be
>>>>fixed in SP1. I can't seem
>>>>to figure out if it has been fixed or not. It still seems we have to add
>>>>the declaration at the
>>>>top
>>>>of each and every single code module. Am I missing something here?
>>>>
>>>--
>>>-C. Moya
>>>www.cmoya.com
>>>>
>>>
>>>
>>>


>>
>>


>
>
>


Correct. If you have an existing VB project, you can set it in the project
project properties.

Mike.

"sticky" <stickymail@dotnet.itags.org.gmail.comwrote in message
news:1169111821.641129.287200@dotnet.itags.org.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

>I havent used VB.Net in a while, I only use C# nowadays, but I seem to
remember that if you want to set option strict globally you need to
open visual studio to the start page, with no project loaded and change
the option strict setting then. all new projects from then on will be
option strict by default.
>
worth a try, but as I said, I haven't used VB for a while
>
C. Moya wrote:

Quote:

Originally Posted by

>I fully expected the lack of a way to set Option Strict globally to be
>fixed
>in SP1. I can't seem to figure out if it has been fixed or not. It still
>seems we have to add the declaration at the top of each and every single
>code module. Am I missing something here?
>>
>--
>-C. Moya
>www.cmoya.com


>
>


Sure... you can set it in many places... like Tools|Options and Project
Properties for WINFORMS apps (which works) and web.config for ASP.NET 2.0
projects. The problem is that it DOES NOT WORK for ASP.NET 2.0 projects.

Apparently, you have to manually insert Option Strict On at the top of each
and every code module in ASP.NET 2.0 projects.

I read this has something to do with 2.0's "project-less" infrastructure...
but it's still a bug nonetheless.

--
-C. Moya
www.cmoya.com
"Michael D. Ober" <obermd.@dotnet.itags.org..alum.mit.edu.no.spamwrote in message
news:75Xrh.12849$w91.5567@dotnet.itags.org.newsread1.news.pas.earth link.net...

Quote:

Originally Posted by

Correct. If you have an existing VB project, you can set it in the
project project properties.
>
Mike.
>
"sticky" <stickymail@dotnet.itags.org.gmail.comwrote in message
news:1169111821.641129.287200@dotnet.itags.org.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

>>I havent used VB.Net in a while, I only use C# nowadays, but I seem to
>remember that if you want to set option strict globally you need to
>open visual studio to the start page, with no project loaded and change
>the option strict setting then. all new projects from then on will be
>option strict by default.
>>
>worth a try, but as I said, I haven't used VB for a while
>>
>C. Moya wrote:

Quote:

Originally Posted by

>>I fully expected the lack of a way to set Option Strict globally to be
>>fixed
>>in SP1. I can't seem to figure out if it has been fixed or not. It still
>>seems we have to add the declaration at the top of each and every single
>>code module. Am I missing something here?
>>>
>>--
>>-C. Moya
>>www.cmoya.com


>>
>>


>
>
>


You can set it, but it doesn't work as expected.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Michael D. Ober" <obermd.@dotnet.itags.org..alum.mit.edu.no.spamwrote in message
news:75Xrh.12849$w91.5567@dotnet.itags.org.newsread1.news.pas.earth link.net...

Quote:

Originally Posted by

Correct. If you have an existing VB project, you can set it in the project project properties.
>
Mike.


Quote:

Originally Posted by

"sticky" <stickymail@dotnet.itags.org.gmail.comwrote in message
news:1169111821.641129.287200@dotnet.itags.org.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

>>I havent used VB.Net in a while, I only use C# nowadays, but I seem to
>remember that if you want to set option strict globally you need to
>open visual studio to the start page, with no project loaded and change
>the option strict setting then. all new projects from then on will be
>option strict by default.
>>
>worth a try, but as I said, I haven't used VB for a while
>>
>C. Moya wrote:

Quote:

Originally Posted by

>>I fully expected the lack of a way to set Option Strict globally to be fixed
>>in SP1. I can't seem to figure out if it has been fixed or not. It still
>>seems we have to add the declaration at the top of each and every single
>>code module. Am I missing something here?
>>>
>>--
>>-C. Moya
>>www.cmoya.com


>>
>>


>
>
>


re:

Quote:

Originally Posted by

Apparently, you have to manually insert Option Strict On at the top of each and every code module
in ASP.NET 2.0 projects.


Unless you modify the project templates as I outlined.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message news:%23ul1as4OHHA.400@dotnet.itags.org.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Sure... you can set it in many places... like Tools|Options and Project Properties for WINFORMS
apps (which works) and web.config for ASP.NET 2.0 projects. The problem is that it DOES NOT WORK
for ASP.NET 2.0 projects.
>
Apparently, you have to manually insert Option Strict On at the top of each and every code module
in ASP.NET 2.0 projects.
>
I read this has something to do with 2.0's "project-less" infrastructure... but it's still a bug
nonetheless.
>
--
-C. Moya
www.cmoya.com
"Michael D. Ober" <obermd.@dotnet.itags.org..alum.mit.edu.no.spamwrote in message
news:75Xrh.12849$w91.5567@dotnet.itags.org.newsread1.news.pas.earth link.net...

Quote:

Originally Posted by

>Correct. If you have an existing VB project, you can set it in the project project properties.
>>
>Mike.
>>
>"sticky" <stickymail@dotnet.itags.org.gmail.comwrote in message
>news:1169111821.641129.287200@dotnet.itags.org.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

>>>I havent used VB.Net in a while, I only use C# nowadays, but I seem to
>>remember that if you want to set option strict globally you need to
>>open visual studio to the start page, with no project loaded and change
>>the option strict setting then. all new projects from then on will be
>>option strict by default.
>>>
>>worth a try, but as I said, I haven't used VB for a while
>>>
>>C. Moya wrote:
>>>I fully expected the lack of a way to set Option Strict globally to be fixed
>>>in SP1. I can't seem to figure out if it has been fixed or not. It still
>>>seems we have to add the declaration at the top of each and every single
>>>code module. Am I missing something here?
>>>>
>>>--
>>>-C. Moya
>>>www.cmoya.com
>>>
>>>


>>
>>
>>


>
>


"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
news:O7h2fa7OHHA.4332@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>Apparently, you have to manually insert Option Strict On at the top of
>each and every code module in ASP.NET 2.0 projects.


>
Unless you modify the project templates as I outlined.
Juan T. Llibre, asp.net MVP


Sigh. So it hasn't been fixed in SP1.
Thanks Juan... I've known about that "workaround" for eons. I was hoping SP1
fixed it.
It's truly (IMO) a dumbfounding lack of foresight on the part of the asp.net
team.

--
-C. Moya
www.cmoya.com
re:

Quote:

Originally Posted by

It's truly (IMO) a dumbfounding lack of foresight on the part of the asp.net team


Actually, the ASP.NET team has nothing to do with that.
The problem belongs to the Visual Studio Dev Team, not to the ASP.NET Dev Team.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"C. Moya" <cmm@dotnet.itags.org.nospam.comwrote in message news:OTb1yQBPHHA.324@dotnet.itags.org.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.comwrote in message
news:O7h2fa7OHHA.4332@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>re:

Quote:

Originally Posted by

>>Apparently, you have to manually insert Option Strict On at the top of each and every code
>>module in ASP.NET 2.0 projects.


>>
>Unless you modify the project templates as I outlined.
> Juan T. Llibre, asp.net MVP


>
Sigh. So it hasn't been fixed in SP1.
Thanks Juan... I've known about that "workaround" for eons. I was hoping SP1 fixed it.
It's truly (IMO) a dumbfounding lack of foresight on the part of the asp.net team.
>
--
-C. Moya
www.cmoya.com
>

0 comments:

Post a Comment