Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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]

like image 605
Jurij B Avatar asked Nov 10 '17 10:11

Jurij B


1 Answers

Thanks for sharing your fix. Unfortunately, that didn't work for me. What worked for me is to reinstall the latest OmniSharp.

Copy-pasted from this ticket:

The fix for this has been pushed into OmniSharp. You should be able to get the fix by setting the "omnisharp.path" option in VS Code to "latest". That will cause C# for VS Code to download the latest build OmniSharp at start up.

like image 137
Annie Lagang Avatar answered Oct 10 '22 14:10

Annie Lagang