Option Strict by default

TechnoTone

Well-known member
Joined
Jan 20, 2003
Messages
224
Location
UK - London
Ive 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 cant 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 cant 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 (theyre there somewhere) and modifying them.
 
Ive already checked them (thats where I removed the references to the Microsoft.VisualBasic namespace) but Option Strict/Explicit isnt there.

I have been wondering whether you could do something with the scripts in the VBWizards folder but its 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 wasnt 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, theyre not all bad anyway.
 
Originally posted by VolteFace
On a side note, removing the reference to Microsoft.VisualBasic is
useless; it is required regardless, and will be referenced anyway.

Besides, theyre 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 shouldnt be a concern to anyone however, since the Microsoft.VisualBasic assembly is distributed as an integral part of the .NET Framework.
 
Back
Top