Should new VB.NET projects default to Option Strict On?
0 reputation · 01 Jul 2023, 05:18 UTC
0 reputation · 01 Jul 2023, 05:18 UTC
Visual Basic as a language does not implement authentication or credential expiration. Least-privilege enforcement and expired credential detection are provided by the .NET runtime, Windows security and application code, not by VB syntax.
The documented language behavior relevant here is VB.NET's permissive type system and late binding, controlled by Option Strict, Option Explicit and Option Infer. Option Strict Off allows implicit narrowing conversions and late binding via Object, which can hide errors at compile time and defer failures to runtime.
An unresolved design decision is the default for new projects: enforcing type safety with Option Strict On versus preserving backward compatibility for legacy VB6 migration code that relies on permissive conversions and late binding.
Does the current SDK-style VB.NET project template default Option Strict to On or Off? Which project settings control late binding availability under current Visual Studio and .NET SDK versions? When defaults are changed, how is compatibility for existing codebases addressed?
No – the current VB.NET project templates (both legacy and SDK‑style) ship with Option Strict set to Off.
Keeping Option Strict Off preserves the permissive VB6‑style conversion and late‑binding behavior that eases migration of older code, even though it moves potential type errors to runtime.
<OptionStrict>Off</OptionStrict> in the generated .vbproj file.<OptionStrict>On</OptionStrict> into the .vbproj file..vbproj if you prefer editing the file manually.To confirm the current default before making changes, inspect a freshly created project’s .vbproj for the OptionStrict element or look at the Compile tab.
Missing diagnostic detail: Which version of Visual Studio (or .NET SDK) are you using to create the project? If the template has already been changed to default Option Strict On, the steps above would not be needed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.