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

option strict

P: n/a
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1.

In my web.config I have:

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

In my Tools/Options/Projects and solutions/vb defaults I have option
strict on.

In my .vb file I have:

Dim NiceBug As Boolean = "Hello world"

which happily compiles. Not so happy at runtime though.

I'd appreciate some advice as to how I get option strict enabled in my
projects without having to add it to every file manually.

And what exactly do the options I've described above actually affect?

Jun 22 '07 #1
Share this Question
Share on Google+
18 Replies


P: n/a
use C#

Poldie wrote:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1.

In my web.config I have:

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

In my Tools/Options/Projects and solutions/vb defaults I have option
strict on.

In my .vb file I have:

Dim NiceBug As Boolean = "Hello world"

which happily compiles. Not so happy at runtime though.

I'd appreciate some advice as to how I get option strict enabled in my
projects without having to add it to every file manually.

And what exactly do the options I've described above actually affect?
Jun 22 '07 #2

P: n/a
re:
!I'd appreciate some advice as to how I get option strict enabled in my
!projects without having to add it to every file manually.

change the default value of Option Strict for VB.NET, follow these steps:

Locate WebApplication.vbproj, inside:
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\VisualBasic\Web\1033\*WebApplicationProject.zi p

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

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 español : http://asp.net.do/foros/
======================================

"Poldie" <Po****@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1.

In my web.config I have:

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

In my Tools/Options/Projects and solutions/vb defaults I have option
strict on.

In my .vb file I have:

Dim NiceBug As Boolean = "Hello world"

which happily compiles. Not so happy at runtime though.

I'd appreciate some advice as to how I get option strict enabled in my
projects without having to add it to every file manually.

And what exactly do the options I've described above actually affect?


Jun 22 '07 #3

P: n/a
On Jun 23, 12:44 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!I'd appreciate some advice as to how I get option strict enabled in my
!projects without having to add it to every file manually.

change the default value of Option Strict for VB.NET, follow these steps:

Locate WebApplication.vbproj, inside:
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\VisualBasic\Web\1033\*WebApplicationProject.zi p

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

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.
I'll give that a go, although it sounds like something which might
come into effect when I next create a new project rather than change
my existing one.

As I explained above, I've already changed my entry in web.config and
in the menu, so if your solution works, where is it changing the
setting, and can I not set it myself manually?

Cheers,
Poldie.

Jun 23 '07 #4

P: n/a
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
As I explained above, I've already changed my entry in web.config and
in the menu, so if your solution works, where is it changing the
setting, and can I not set it myself manually?
Have you tried Tools, Options, Projects and Solutions, VB Defaults?

No idea if this will modify existing projects, though, as I never go
anywhere near VB.NET...
--
http://www.markrae.net

Jun 23 '07 #5

P: n/a
On Jun 23, 11:08 am, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"Poldie" <Pol...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
As I explained above, I've already changed my entry in web.config and
in the menu, so if your solution works, where is it changing the
setting, and can I not set it myself manually?

Have you tried Tools, Options, Projects and Solutions, VB Defaults?
No idea if this will modify existing projects, though, as I never go
anywhere near VB.NET...
Yeah, I believe I explained that in my first post. I also tried in
web.config. Neither had any effect - only adding a line of text to
each file manually.


Jun 23 '07 #6

P: n/a
re:
!Have you tried Tools, Options, Projects and Solutions, VB Defaults?
!No idea if this will modify existing projects, though, as I never go anywhere near VB.NET...

It doesn't even change the setting for *new* projects, Mark.

re:
!where is it changing the setting, and can I not set it myself manually?

There's no way to change the setting at design time, for new projects,
because the change is needed in the project *template*.

Devenv.exe creates a new project based on the existing templates,
and the default for that is option "strict= false".

Changing the option, in the template's web.config, is the only solution.

Btw, the directory location in my earlier post is either incorrect or was changed by SP1.

Instead of :
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\VisualBasic\Web\1033\*WebApplicationProject.zi p

The correct path is :
Drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\Web\VisualBasic\1033\WebApplication.zip

Extract web.config from that zip file, change <compilation debug="false" strict="false"
explicit="true" />
to <compilation debug="false" strict="true" explicit="true" />

and zip it up again, updating WebApplication.zip
That will automatically create/compile projects with that strict="true" configured.

And, btw, that's not behavior "by design". It's a bug.


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/
======================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:eb*************@TK2MSFTNGP04.phx.gbl...
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>As I explained above, I've already changed my entry in web.config and
in the menu, so if your solution works, where is it changing the
setting, and can I not set it myself manually?

Have you tried Tools, Options, Projects and Solutions, VB Defaults?

No idea if this will modify existing projects, though, as I never go anywhere near VB.NET...
--
http://www.markrae.net

Jun 23 '07 #7

P: n/a
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:el**************@TK2MSFTNGP03.phx.gbl...
re:
!Have you tried Tools, Options, Projects and Solutions, VB Defaults?
!No idea if this will modify existing projects, though, as I never go
anywhere near VB.NET...

It doesn't even change the setting for *new* projects, Mark.
Really...? Then what on earth does that setting do...?
And, btw, that's not behavior "by design". It's a bug.
Thank God I use C#... :-)
--
http://www.markrae.net

Jun 23 '07 #8

P: n/a
On Jun 23, 3:28 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!Have you tried Tools, Options, Projects and Solutions, VB Defaults?
!No idea if this will modify existing projects, though, as I never go anywhere near VB.NET...

It doesn't even change the setting for *new* projects, Mark.

re:
!where is it changing the setting, and can I not set it myself manually?

There's no way to change the setting at design time, for new projects,
because the change is needed in the project *template*.

Devenv.exe creates a new project based on the existing templates,
and the default for that is option "strict= false".

Changing the option, in the template's web.config, is the only solution.

Btw, the directory location in my earlier post is either incorrect or waschanged by SP1.

Instead of :
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\VisualBasic\Web\1033\*WebApplicationProject.zi p

The correct path is :
Drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\Web\VisualBasic\1033\WebApplication.zip

Extract web.config from that zip file, change <compilation debug="false" strict="false"
explicit="true" />
to <compilation debug="false" strict="true" explicit="true" />

and zip it up again, updating WebApplication.zip
That will automatically create/compile projects with that strict="true"configured.
Ok pay attention! I've I explained earlier, I've already set my
web.config file, manually, with the appropriate text:

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

It's not having any effect. Therefore fiddling in zip files is going
to have the same effect next time I create a new project - no effect
whatsoever. The only thing which makes a difference is setting the
option at the top of each page. I appreciate that this isn't a
problem in c#, but this doesn't help me as I'm not developing in c#.

Jun 23 '07 #9

P: n/a
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@u2g2000hsc.googlegro ups.com...
Ok pay attention!
Oh dear... :-)
It's not having any effect.
That's right - it won't have any effect - Juan has just explained to you why
that is...
Therefore fiddling in zip files is going to have the same effect next time
I create
a new project - no effect whatsoever.
No - "fiddling" in zip files is going to solve your problem for you because
you will be changing the templates from which new projects and pages are
created...

You need to actually do as Juan has suggested...
The only thing which makes a difference is setting the option at the top
of each
page
Which you will no longer have to do if you modify the template from which
the new pages are created...
--
http://www.markrae.net

Jun 23 '07 #10

P: n/a
re:
!Ok pay attention! I've I explained earlier, I've already set my
!web.config file, manually, with the appropriate text:

!<compilation debug="true" strict="true" />

No. *You* pay attention. I've already explained it's a *bug*.
It's been fixed in VS 2005 SP1.

re:
!It's not having any effect.

This isn't an ASP.NET bug. It's a VS 2005 bug.

Nothing you do, as far as ASP.NET configuration goes,
will affect the way VS 2005 compiles source files.

What you *can* do, and works, is install VS 2005 SP1.

*Then*, when you change Tools/Options/Projects and Solutions/VB Defaults to
option strict on, and you change the web.config to strict="true", and you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

....you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")

Never mind that the suggested change is bonkers, though. :-)
At least it flags the error as an error which will not compile correctly.


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/
======================================
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@u2g2000hsc.googlegro ups.com...
On Jun 23, 3:28 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!Have you tried Tools, Options, Projects and Solutions, VB Defaults?
!No idea if this will modify existing projects, though, as I never go anywhere near VB.NET...

It doesn't even change the setting for *new* projects, Mark.

re:
!where is it changing the setting, and can I not set it myself manually?

There's no way to change the setting at design time, for new projects,
because the change is needed in the project *template*.

Devenv.exe creates a new project based on the existing templates,
and the default for that is option "strict= false".

Changing the option, in the template's web.config, is the only solution.

Btw, the directory location in my earlier post is either incorrect or was changed by SP1.

Instead of :
drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\VisualBasic\Web\1033\*WebApplicationProject.zi p

The correct path is :
Drive:\VStudioInstallDir\Common7\IDE\ProjectTempla tes\Web\VisualBasic\1033\WebApplication.zip

Extract web.config from that zip file, change <compilation debug="false" strict="false"
explicit="true" />
to <compilation debug="false" strict="true" explicit="true" />

and zip it up again, updating WebApplication.zip
That will automatically create/compile projects with that strict="true" configured.
Ok pay attention! I've I explained earlier, I've already set my
web.config file, manually, with the appropriate text:

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

It's not having any effect. Therefore fiddling in zip files is going
to have the same effect next time I create a new project - no effect
whatsoever. The only thing which makes a difference is setting the
option at the top of each page. I appreciate that this isn't a
problem in c#, but this doesn't help me as I'm not developing in c#.

Jun 23 '07 #11

P: n/a
On Jun 23, 4:52 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!Ok pay attention! I've I explained earlier, I've already set my
!web.config file, manually, with the appropriate text:

!<compilation debug="true" strict="true" />

No. *You* pay attention. I've already explained it's a *bug*.
It's been fixed in VS 2005 SP1.
I've got SP1. At least, I installed it. Of course, Microsoft being
Microsoft, they don't bother to put "SP1" on the Help screen so I can
confirm this. I definitely sat around for over an hour waiting for
the service pack to do somthing, a few months ago. Perhaps it failed
silently though. Wouldn't surprise me.
This isn't an ASP.NET bug. It's a VS 2005 bug.
I can believe this.
Nothing you do, as far as ASP.NET configuration goes,
will affect the way VS 2005 compiles source files.

What you *can* do, and works, is install VS 2005 SP1.

*Then*, when you change Tools/Options/Projects and Solutions/VB Defaults to
option strict on, and you change the web.config to strict="true", and you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

...you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")
Well, no, it won't.
Never mind that the suggested change is bonkers, though. :-)
At least it flags the error as an error which will not compile correctly.
That'll do me! I'm going to fiddle with the zip files in just a few
moments (after I've confirmed SP1 installed properly on my machine)
and see what happens. I guess I'll have to create a new project and
create new pages and cut and paste my code into them to take advantage
of the newly enabled status of `option strict`, right?
Jun 23 '07 #12

P: n/a
Note: SP1 was installed on my system. So why isn't the `projects and
solutions` or web.config option having any effect?

I'll try the `fiddling with zip files` "solution" now, even though
you're saying I shouldn't have to, and see if that helps. If it does,
what is it changing, exactly? If it doesn't just add the text to the
top of my source files for me when I create them, and it doesn't set a
value in web.config, then what does it do?

Thanks for the help, by the way!

Jun 23 '07 #13

P: n/a
re:
!Of course, Microsoft being Microsoft, they don't bother to
!put "SP1" on the Help screen so I can confirm this.

Look in "Help", "About Microsoft Visual Studio".

It's not evident ( it's cutoff ), but if you click the "Copy Info" button,
and paste it into a text file, you'll see this :

"Microsoft Visual Studio 2005 - ENU Service Pack 1 (KB926601)"

That tells you SP1 installed successfully.

If you don't see that... you don't have SP1 installed.


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/
======================================
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.com...
On Jun 23, 4:52 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
>re:
!Ok pay attention! I've I explained earlier, I've already set my
!web.config file, manually, with the appropriate text:

!<compilation debug="true" strict="true" />

No. *You* pay attention. I've already explained it's a *bug*.
It's been fixed in VS 2005 SP1.

I've got SP1. At least, I installed it. Of course, Microsoft being
Microsoft, they don't bother to put "SP1" on the Help screen so I can
confirm this. I definitely sat around for over an hour waiting for
the service pack to do somthing, a few months ago. Perhaps it failed
silently though. Wouldn't surprise me.
>This isn't an ASP.NET bug. It's a VS 2005 bug.

I can believe this.
>Nothing you do, as far as ASP.NET configuration goes,
will affect the way VS 2005 compiles source files.

What you *can* do, and works, is install VS 2005 SP1.

*Then*, when you change Tools/Options/Projects and Solutions/VB Defaults to
option strict on, and you change the web.config to strict="true", and you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

...you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")

Well, no, it won't.
>Never mind that the suggested change is bonkers, though. :-)
At least it flags the error as an error which will not compile correctly.

That'll do me! I'm going to fiddle with the zip files in just a few
moments (after I've confirmed SP1 installed properly on my machine)
and see what happens. I guess I'll have to create a new project and
create new pages and cut and paste my code into them to take advantage
of the newly enabled status of `option strict`, right?


Jun 24 '07 #14

P: n/a
re:
!Note: SP1 was installed on my system.

OK...

!So why isn't the `projects and solutions` or web.config option having any effect?

Maybe because SP1 doesn't work with "web projects" any more ?

Try creating a new "web site" ( either "HTTP" or "File system" -based ),
change Tools/Options/Projects and Solutions/VB Defaults to option strict on,
and change web.config to strict="true", and when you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

....you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")


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/
======================================
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Note: SP1 was installed on my system. So why isn't the `projects and
solutions` or web.config option having any effect?

I'll try the `fiddling with zip files` "solution" now, even though
you're saying I shouldn't have to, and see if that helps. If it does,
what is it changing, exactly? If it doesn't just add the text to the
top of my source files for me when I create them, and it doesn't set a
value in web.config, then what does it do?

Thanks for the help, by the way!


Jun 24 '07 #15

P: n/a
On Jun 24, 1:09 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!Note: SP1 was installed on my system.

OK...

!So why isn't the `projects and solutions` or web.config option having any effect?

Maybe because SP1 doesn't work with "web projects" any more ?

Try creating a new "web site" ( either "HTTP" or "File system" -based ),
change Tools/Options/Projects and Solutions/VB Defaults to option strict on,
and change web.config to strict="true", and when you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

...you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")

I do have SP1 installed.

I created a brand new web application and dragged the files from my
old `web site` into it, and after some fiddling and confusion and
surfing I think I'm up and running again. I have a solution file now,
and a .designer.vb file for each page of my app. (I'm not quite sure
what the point of the .designer.vb file is as the `design` of the page
is in the .aspx file.) I notice that I no longer have an `app_code`
and `app_data` folder, but as my app is working I won't worry about
that.

I also have option strict on. (In fact, now I can't turn it off, but
I'll worry about that when I need to!)

Microsoft certainly seems to have angered and confused a lot of people
with all this `in 2003, not in 2005, in an add-on, finally in a SP but
uninstall stuff in the right order or else!` business but perhaps
they've got there in the end. I wonder if they'll remove the `web
site` style in the next release?

Thanks for the help.

Jun 24 '07 #16

P: n/a
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
I wonder if they'll remove the `web site` style in the next release?
It wouldn't bother me one bit if they did, but apparently it's here to
stay...

There was a thread about this a few months ago...
--
http://www.markrae.net

Jun 24 '07 #17

P: n/a
re:
!I created a brand new web application and dragged the files from my
!old `web site` into it, and after some fiddling and confusion and
!surfing I think I'm up and running again. I also have option strict on.

That's good to know.

re:
!I'm not quite sure what the point of the .designer.vb file
!is as the `design` of the page is in the .aspx file.

The .designer files contain the field declarations for the controls in the .aspx page.
It's auto-generated, so you don't have to write the declarations manually.

re:
!Thanks for the help.

You're quite welcome. I'm glad to know you're up and running again.

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/
======================================
"Poldie" <Po****@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On Jun 24, 1:09 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
>re:
!Note: SP1 was installed on my system.

OK...

!So why isn't the `projects and solutions` or web.config option having any effect?

Maybe because SP1 doesn't work with "web projects" any more ?

Try creating a new "web site" ( either "HTTP" or "File system" -based ),
change Tools/Options/Projects and Solutions/VB Defaults to option strict on,
and change web.config to strict="true", and when you add to a .vb file :

Dim NiceBug As Boolean = "Hello world"

...you will see that the VS 2005 IDE flags it as an error,
and suggests you change the line to : Dim NiceBug As Boolean = CBool("Hello world")


I do have SP1 installed.

I created a brand new web application and dragged the files from my
old `web site` into it, and after some fiddling and confusion and
surfing I think I'm up and running again. I have a solution file now,
and a .designer.vb file for each page of my app. (I'm not quite sure
what the point of the .designer.vb file is as the `design` of the page
is in the .aspx file.) I notice that I no longer have an `app_code`
and `app_data` folder, but as my app is working I won't worry about
that.

I also have option strict on. (In fact, now I can't turn it off, but
I'll worry about that when I need to!)

Microsoft certainly seems to have angered and confused a lot of people
with all this `in 2003, not in 2005, in an add-on, finally in a SP but
uninstall stuff in the right order or else!` business but perhaps
they've got there in the end. I wonder if they'll remove the `web
site` style in the next release?

Thanks for the help.

Jun 24 '07 #18

P: n/a
On Jun 24, 2:13 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
re:
!I created a brand new web application and dragged the files from my
!old `web site` into it, and after some fiddling and confusion and
!surfing I think I'm up and running again. I also have option strict on.

That's good to know.

re:
!I'm not quite sure what the point of the .designer.vb file
!is as the `design` of the page is in the .aspx file.

The .designer files contain the field declarations for the controls in the .aspx page.
It's auto-generated, so you don't have to write the declarations manually.
But I wasn't writing any declarations before, in the web site model,
when I just had an .aspx and .aspx.vb for each page!

Another quirk was that when I dragged my files from my web site folder
the the solution explorer in the web application project, one of them
wasn't processed properly and I had to make a few changes. They were
pretty simple changes but it was confusing for me because this is my
first asp.net project. It's been a confusing few weeks, really, with
me trying to get to grips with the web development model in general,
asp.net 2.0 sp1 and the fact that most of the books and sites out
there are for some earlier (or later, in a few cases) versions of
asp.net. I'm getting there, but I've got a mountain of books and
printouts to get through!

Jun 24 '07 #19

This discussion thread is closed

Replies have been disabled for this discussion.