Jeremiah Mercier
Jeremiah Mercier

Reputation: 501

How do I resolve "The type or namespace 'System' could not be found" with UWP 6.2.10?

I'm trying to build a project using Microsoft.NETCore.UniversalWindowsPlatform version 6.2.10 and I get numerous build errors such as:

error CS0246: The type or namespace 'System' could not be found (are you missing a using directive or an assembly reference?)
error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib'.
error CS0518: Predefined type 'System.Object' is not defined or imported
error CS0518: Predefined type 'System.Boolean' is not defined or imported
error CS0246: The type or namespace name 'AssemblyTitleAttribute' could not be found (are you missing a using directive or an assembly reference?)

Other developers on my team are able to build the project successfully using the exact same code.

If I downgrade the NuGet package Microsoft.NETCore.UniversalWindowsPlatform to version 6.2.9 without making any other changes, it builds fine.

I tested this by creating a brand new Blank App (Universal Windows) project in Visual Studio 2019, which uses version 6.2.9 of the NuGet package by default. I didn't make any changes to the template created by Visual Studio. This builds fine. Then I upgraded the NuGet package to version 6.2.10 without making any other changes. It fails with build errors similar to the errors above.

How do I resolve these errors?

Upvotes: 1

Views: 4694

Answers (1)

Jeremiah Mercier
Jeremiah Mercier

Reputation: 501

I was eventually able to resolve this by clearing the NuGet cache, then removing and re-adding the NuGet package. Both steps were necessary to resolve the errors.

To clear the NuGet cache, click Tools → NuGet Package Manager → Package Manager Settings → NuGet Package Manager → General → Clear All NuGet Cache(s).

Upvotes: 3

Related Questions