"Predefined Type" System. * "Not defined or not imported" Error, visual studio code, omnisharp

I am having a problem with this error in several major .net applications. I am using vs code version 1.18.0, but the error began to appear already in the previous version.

An error appears in each .cs file for each data type, such as string, int, void, etc., as well as for importing classes.

All projects are still compiled and run properly. Also on another workstation I'm not having a problem in the same projects, so it looks like this is local code or omnisharp / vs windows? problem.

Has anyone had something like this and managed to fix it or some suggestions about what I could try?

I reinstalled vs code and omnisharp already, but I still have a problem.

Example Error: The predefined type "System.Object" is not defined or not imported [GG]

+5
source share
1 answer

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

short version . I changed the msbuild omnisharp instance using uninstall Visual Studio 2017 Pro .

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

About a week ago, I opened it (by accident: D) ​​and received a notification that my trial period has expired, also VS is blocked. This did not bother me, because I did not use it. In @VahidN Link, I found that omnisharp uses the “most native” instance of msbuild that was installed, which in my case was one of the blocked VS 2017 Pro. 1 + 1 I did not install VS and I am good.

I will reinstall VS 2017 (Comunity) and leave a comment if it still works fine.

EDIT:: I reinstalled VS 2017, everything works fine, so the current solution updates VS 2017 , which I could not do because it was blocked.

+1
source

Source: https://habr.com/ru/post/1273260/


All Articles