Error CS0518 Predefined type 'System.String' is not defined or imported

67 views Asked by At

When building the C# (.NET 6) project with unit tests, I have found the error CS0518:

Predefined type 'System.String' is not defined or imported

I was trying to add using System.String, to the file with the method causing the error, but without success.

Between other error messages, after rebuilding, I also found messages about version conflicts.

How to resolve this error message?

1

There are 1 answers

0
Gerard Jaryczewski On

The error messages about version conflicts were related to the upgrade of .NET in connected projects in the same solution. The main project, which was the system under test, System.String namespace has a greater version (.NET 8).

After adjusting the version of the test project the errors disappeared.