Project Properties don't open - "There are no property pages for the selection"
I've found the source of the problem! The problem lay in my VCTargetsPath
system environment variable.
It turns out my VCTargetsPath
was set to:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
-- which seems correct; that's the right directory.
Unfortunately, it's missing the final backslash - it needs to be:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\
Without that backslash at the end, it doesn't work.
Apparently the issues I was having were various instances of Visual Studio trying to weld paths incorrectly on top of this path, e.g. the following error I got trying to build an android project (note bold):
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Clang.targets(210,5): error MSB4062: The "ClangCompile" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140Microsoft.Build.CppTasks.Common.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140Microsoft.Build.CppTasks.Common.dll or one of its dependencies. The system cannot find the file specified.
I've fixed the variable and it has, indeed, solved this issue (and several clearly related issues I discovered after the first one.)
If other users are experiencing similar issues, I strongly advise that they examine the VCTargetsPath
for possible errors, and particularly for the missing final backslash.
In the interest of assisting others with the same issue, here are the various problems I was experiencing. All of these pertaining to C++ projects only, and all of them solved by the fix I described.
1. Errors when creating new project. If I try to create a new C++ project in a solution (e.g. an Empty C++ Project), I get two error messages:
'null' is null or not an object
Exception from HRESULT: 0x800A138F
The project is then created -- although in the status bar at the bottom of the screen, I see a message reading: Creating 'Project1' ... project creation failed.
2. Cannot add existing file to project. If I attempt to add an existing source file to a project, I get two consecutive error messages reading:
The desired name for C:\tmp\foo.cpp is invalid.
The operation could not be completed. The parameter is incorrect.
The file is not added to the solution.
3. Cannot access Project Properties or Property Pages. When I try to access a project's properties, I get a white popup with the header MyProject Property Pages
(where MyProject
is the project name) and the error: There are no property pages for the selection.
If I try to view property pages I get the same error, except instead of the project name, the header has the name of the property page, e.g. Microsoft.Cpp.Win32.user Property Pages
.
4. Visual Studio does not recognize when a project is not up-to-date. Visual Studio still builds my C++ projects, and builds them correctly. However, once I build a project, I have a new problem: making a change to a source file and then performing another build does nothing - the output lists the project as being up-to-date, even when it isn't. To build correctly, I now need to force a rebuild.