Can I set Option Explicit and Option Strict at the Project / Solution level?

I really like the coding speed that VB.NET provides, but I don’t like to forget to declare variable types, return function types, etc., which is why in each class I use:

Option Explicit On Option Strict On 

Is there a way to define these two options at the project / decision level?
It is very tedious to copy these two options in each class ... We are coding Visual Studio 2010 in the .NET Client Client.

+7
visual-studio visual-studio-2010
source share
2 answers

Yes , you can set these parameters for the entire project in your project. Properties:

  • Right-click on your project in Solution Explorer and select "Properties" from the context menu.
  • Click the Compile tab in the list on the left.
  • Set the dropdown lists as desired.

Project properties - Compile tab - Compile Options


You can also specify these options globally in Visual Studio options (although this will only affect new projects, not existing ones):

  • In Visual Studio, click "Tools" and select "Options."
  • Expand the Projects and Solutions item in the tree on the left side of the dialog box.
  • Select "VB Defaults".
  • Set "Project Default Settings" as desired.

VS Options - Projects and Solutions - VB Defaults - Default project settings

+12
source share

Well, the obvious place is to look in the project parameters dialog, and here it is:

Visual Basic .NET Project Options

+2
source share

All Articles