Sam
Sam

Reputation: 976

Option Strict Intellisense errors but compiles fine

I have just got a new work PC and am moving a solution from VS15 to 17.

When I edit existing source files, I get a bunch of errors relating to option strict, which include:

Option Strict On requires all variable declarations to have an 'As' clause
Option Strict On disallows implicit conversions from 'Object' to 'Integer'
Option Strict prohibits operands of type Object for operator '-'
Option Strict On disallows late binding

In addition to this, I am getting errors about System classes not being found, for example Attribute, NotImplementedException, etc.

Option Strict is turned off for all solutions in the project.

The errors relating to Object to Integer are caused by i variables within loops, where the for line also has an error about late binding being disallowed.

I have tried deleting the vs folder within the solution but it made no difference.

The project compiles without issue. How can I fix the Intellisense errors?

Upvotes: 5

Views: 866

Answers (2)

MatSnow
MatSnow

Reputation: 7517

Probably it is the VS 2017 bug (v. 15.5.0) described here.
Occurred today with me after I updated VS from 15.4 to 15.5.

The workaround has already been posted in Drake's answer.

Uncheck option Allow parallel project initialization (Tools > Options > Projects and Solutions > General). Reopen the solution.

EDIT
This has been fixed with the latest update (v. 15.5.1).

Upvotes: 2

Drake
Drake

Reputation: 8392

I think that there is a problem with the .suo files (or sqlite3 files) and VB.NET in Visual Studio 15.5.

Deleting .suo file manually or even the full .vs project subfolder doesn't solve it.

You need to open the solution, go to My Project -> Properties -> References.

You'll see that the Imported Namespaces in the bottom are all unchecked.

Scroll to System and enable it (mouse double click or space).

You'll probably receive an exception "Index was outside the bounds of array". Just ignore it but the intellisense problem should be solved now.

You have to do it for every VB.NET project is loaded with the solution.

It is the only workaround I found. I hope that they will fix it in the next release.

enter image description here

Another workaround: Disable Parallel Project Initialization

I found another workaround in the Visual Studio Feedback page (https://developercommunity.visualstudio.com/content/problem/160241/errors-reported-when-none-exist.html). Credits to Peter van den Berge.

enter image description here

Uncheck option "Allow parallel project initialization" (Tools > Options > Projects and Solutions > General). Reopen the solution.

Upvotes: 7

Related Questions