Okay, I need to give you some history of .NET… at first, by default, Options Strict was turned on. This is a good thing! It makes for better bug free code. Many of us have been waiting for this for a long time. But, some of the big-wigs in the VB world started crying?!?!
Why… because they said that this would hamper their efforts to migrate VB6 code to VB.NET. Ha! Migrating code is a pipe dream and should be avoided at all costs. For some STUPID reason Microsoft actually listened to them and in the final release of VB.NET turned it off. So now, when a new project is created, we have to remember to go turn it on. What a pain!
Well, there is a way to fix it, but it’s not pretty. When you create a project in VB.NET using File | New | Project and select a project type, it’s actually using a project template. To find the templates, navigate to:
<drive>:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards
Then it gets kinda tricky. Find the project template folder that needs to be edited. For example, ClassLibrary for creating DLL like assemblies or WindowsApplication for a Windows application (duh). Then navigate to the Templates folder. Then bring up the .vbproj file in an text editor. Under the <Settings> node add the following:
OptionStrict = "On"
You should end up with something that looks like this:
<Settings
OutputType = "Library"
OptionStrict = "On"
StartupObject = ""
>
Save the file and your done! You will need to do this to every project template that you use.
Tip Submitted By: David McCarter
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
