Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 658
Sam Avatar asked Dec 06 '17 01:12

Sam


1 Answers

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.

like image 155
Drake Avatar answered Sep 22 '22 14:09

Drake