Invalid name for <file> - visual studio 2015

This is pretty crazy, I only add the existing .h file to the VS2015 C ++ project, but it will complain:

The required name for c: \ code \ usbview \ USBdevices.h is invalid

I managed to add this file to the project when it had its own .sln file. However, I created a new empty .sln file and wanted to add this and another project and understand how this problem was released. This will not add this project to the new solution giving the same weird error regarding the files I added.

Then I add the base project to this solution file and try to add the .h and .cpp files there, but it adds .cpp but gives this error for the .h file.

This is very strange, I changed the file names, but the same error.

+5
source share
3 answers

The link in the BlackDwarf comment section fixed the problem, even if it was for C #, but applied.

I did not have a USERPROFILE environment variable, so I created it and set it to c: \ Users \ my.name, and now I can add the file

+2
source

If the environment variable route does not work for you, check the integrity of the project file.

I had this problem in 2017 and it was due to double entry in vcxproj from a manual editing error. Our vcxproj file had the following in it:

<ClInclude Include="XXXX.h" /> <ClCompile Include="XXXX.h" />

In 2017, we got exactly the error that you described when trying to add an existing file, slightly different when adding new and strange crashes elsewhere. The discovery of the solution in 2015 launched the exact problem and failed to download the project. We deleted the double entry, and all the mysterious problems disappeared.

0
source

I had the same problem and this was due to merge errors in the ProjectName.vcxproj.filters file.

0
source

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


All Articles