Option Strict by default

TechnoTone

Junior Contributor
Joined
Jan 20, 2003
Messages
224
Location
UK - London
I've searched these forums and found lots of references to Option Strict, most of which say that you should turn this on for all projects. However, I can't find any way to turn this on by default. Is it possible and if so, how?

wyrd mentioned writing an add-in that automatically sets Option Strict to On and removes the Microsoft.VisualBasic import. I can't find any reference in the online help regarding add-ins - how would you go about doing this?
 
The only thing I can think of is finding the new project templates (they're there somewhere) and modifying them.
 
I've already checked them (that's where I removed the references to the Microsoft.VisualBasic namespace) but Option Strict/Explicit isn't there.

I have been wondering whether you could do something with the scripts in the VBWizards folder but it's a little daunting to me.

What about the Add-in idea? Any sources of information on writing add-ins?
 
I had a quick go, and I was able to do this. I opened the file:

Code:
\VS.NET\Vb7\VBWizards\WindowsApplication\Templates\1033\WindowsApplication.vbproj

And added the line:

Code:
OptionStrict = "On"

Just after the OutputType = "WinExe" line.
 
Nice one. Not seeing Option Explicit there I figured it wasn't the correct place. I guess Option Explicit = "On" is a default anyway.

Thanks.
 
On a side note, removing the reference to Microsoft.VisualBasic is
useless; it is required regardless, and will be referenced anyway.

Besides, they're not all bad anyway.
 
VolteFace said:
On a side note, removing the reference to Microsoft.VisualBasic is
useless; it is required regardless, and will be referenced anyway.

Besides, they're not all bad anyway.
Are you sure about that? It works on mine!
 
You can remove the imports statement but you cannot remove the reference. The Visual Basic .NET compiler (vbc.exe) will add the reference regardless, whether a project is compiled from Visual Studio or from the command line. This shouldn't be a concern to anyone however, since the Microsoft.VisualBasic assembly is distributed as an integral part of the .NET Framework.
 
Back
Top