Today I cloned my windows universal app project from github onto a new machine running a new install of Visual Studio 2015.
After the project loaded, I noticed that all of my pages and properties were underlined red with many errors
CS0246 C# The type or namespace name "<name>" could not be found (are you missing a using directive or an assembly reference?)
CS0518 C# Predefined type 'System.Void' is not defined or imported
CS0012 C# The type '' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
CS1545 C# Property, indexer, or event 'Application.Suspending' is not supported by the language; try directly calling accessor methods 'Application.add_Suspending(SuspendingEventHandler)' or 'Application.remove_Suspending(EventRegistrationToken)'
You must add a reference to assembly 'mscorlib, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Looking in the
References of the project in the
Solution Explorer it can be seen that even though
Microsoft.NETCore.UniversalWindowsPlatformis listed as a dependency, it's missing from the project and this is causing the issue.
Visual studio knows that the assembly is a dependency and needs to be referenced but it doesn't seem to come preinstalled with Visual Studio 2015, even when you install all of the Windows 10 development tools during setup, and it doesn't seem to autofetch the package even when it knows it needs it!
To fix, you need to manually install the package using NuGet and it will then be resolved correctly as a reference.
To do this, right click on
References, then click
Manage NuGet Packages....
NuGet Package Manager screen, search for
Microsoft.NETCore.UniversalWindowsPlatform and it will be an exact match.
Install in the details pane on the right hand side and Visual Studio will fetch the package and include it as a reference in your project
The red underlining will then all disappear and you can continue working on your project!