Visual Studio 2015 or 2017 shows IntelliSense erro

2019-01-03 15:33发布

We are currently evaluating the new Visual Studio 2015 and encountered a strange problem with IntelliSense. When I compiled our main solution with the new studio the build succeeds, but nevertheless 6 errors are shown.

I discovered that it's not a real error, but only an intellisense error. The code is definitely correct and everything compiled successfully. The code however is marked red and errors show up in the error list.

All 6 errors have the same origin. It's a simple constructor call. Strange enough, but there are also some occurrences of the exact same constructor without any errors.

The error message:

Code: CS1729
Message: '<the class>' does not contain a constructor that takes that many arguments.
Project: <the project name>
File: <the path to the file>

The new studio was installed on a freshly installed Windows 7 without any legacy software (no VS13).

I've already tried to clear the caches, deleted the suo file, deleted bin and obj directories, cleaned and rebuilt the solution etc. But nothing worked.

Can anyone explain that behavior to me?

10条回答
Animai°情兽
2楼-- · 2019-01-03 15:54

I had multiple stdfax.h in Additional Include Directories. Make sure the stdafx.h you intended is first in your path.

查看更多
做个烂人
3楼-- · 2019-01-03 16:00

Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me

  1. Perform Clean Solution
  2. Close VS
  3. Delete .suo file & Delete bin/obj directories
  4. Reopen VS
查看更多
Deceive 欺骗
4楼-- · 2019-01-03 16:02

I had thousands of intellisense errors and 0 build errors. After deleting .suo file and restarting VS intellisense errors are gone.

Suo file is located relatively to source in: .vs\SolutionName\v14\.suo

According to comment: Beware that *.suo is a hidden file.

Edit: According to comments, VS2017 has the same issue, so you can use similar solution: Delete .vs\SolutionName\v15\.suo

查看更多
时光不老,我们不散
5楼-- · 2019-01-03 16:03

Also had this problem (the title, not the specific error message), as well as squiggly lines in the editor. The first squiggly line is under the first #include statement, which names a precompiled header. Intellisense fails to include the precompiled header, but doesn't list that as an error; instead it lists errors further down the file, on code that (very rightfully) relies on declarations in the precompiled header.

The reason Intellisense doesn't find the precompiled header in my environment is that the header named is not an actual file. It doesn't have to be in any other VC or gcc version I used, nor in the 2015 compiler, as long as the precompiled header settings are correctly configured. Apparently not any more for Intellisense. I'm not entirely sure it was different in 2013, maybe I just never noticed.

In the unlikely case that this would be the problem reported here, the solution is simple: create a small file with the pretend-name of the precompiled header, as specified in #include directives, and let that file include the actual name of the precompiled header.

If you wonder... why this distinction between the precompiled header name in the '#include' statement and the actual filename of the precompiled header? Precisely because it guarantees that precompiled header settings are correctly configured. Wherever a precompiled header is "#included", there is no file around that could be included. Either an actually precompiled (binary) version of the actual header is read, or the compilation fails. Obviously, a disadvantage is that it confuses people reading the code, not just Intellisense.

查看更多
Melony?
6楼-- · 2019-01-03 16:03

Today i've got similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but occasionally i've noticed that stdafx.h of the subproject i had problems with doesn't contain any standard library headers. I suggested that it might slow down module compilation, but inclusion of the standard headers there fixed Intellisense, too.

查看更多
我只想做你的唯一
7楼-- · 2019-01-03 16:03

I had a similar issue with different Visual Studio versions.

Deleting the .suo or .vs folder did not help for me.

The Solution for me was, that I had the Extension StopOnFirstBuildError active. After turning off "Stop build on first error" in the build menu, and after the solution was fully built, the errors shown by Intellisense went away.

查看更多
登录 后发表回答