"Predefined type 'System.*' is not defined or imported" Error, visual studio code, omnisharp

Jurij B picture Jurij B · Nov 10, 2017 · Viewed 9.5k times · Source

I'm having an issue with the mentioned error in several .net core applications. I'm using vs code version 1.18.0 but the error started to appear already in the previous version.

The error appears in every .cs file for every datatype like string, int, void etc. and also for class imports.

All the projects still compile and run properly. Also on another workstation I'm not having the issue in the same projects, so it seems to be a local omnisharp/ vs code or windows? problem.

Has anyone had something like this and managed to fix it or any suggestions on what i could try?

I've reinstalled vs code and omnisharp already, but I'm still having the problem.

example Error: Predefined type 'System.Object' is not defined or imported [GG]

Answer

Jurij B picture Jurij B · Nov 13, 2017

I found a fix ( or workaround) for my problem:

short version: I changed the omnisharp msbuild instance by uninstalling Visual Studio 2017 Pro.

long version: A few months ago I installed VS 2017 Pro to check out the features, used it for 2 weeks in trial mode and forgot about it for several months.

Around one week ago I opened it (by accident :D) and got a notification, that my trial period expired, also VS locked itself. It didn't bother me , because I wasn't using it. In @VahidN 's Link I found out that omnisharp is using "the most native" msbuild instance that is installed, which in my case was the one of the locked VS 2017 Pro. 1+1 I unsinstalled VS and I'm good.

I'll reinstall VS 2017 ( Comunity) and post a comment if it still works fine.

EDIT:: I reinstalled VS 2017, everything works fine, so the actual solution is updating VS 2017, which i couldnt do besause it was locked prieviously.