-
Вопрос заданболее года назад
-
776 просмотров
Закрой приложение.
Удали сгенерируемые .sln файлы в папке с проектом. Открой приложение нажми в External tools -> regenerate project files.
Открой заново после всех манипуляций редактор.
В vsCode по типу такой была ошибка, но с пространством имён UI
Пригласить эксперта
Я вижу, что вы открываете VS не из юнити. Добавьте в настройках юнити в качестве редактора кода VS 2019. К сожалению я не помню путь к этой найтроке, погуглите.
-
Показать ещё
Загружается…
10 июн. 2023, в 04:04
4000 руб./за проект
10 июн. 2023, в 01:43
6500 руб./за проект
10 июн. 2023, в 00:17
5000 руб./за проект
Минуточку внимания
Here’s a collection of popular answers. Upvote the OP of the answer if it helped you:
Option 1: Clean, Build and Refresh (@Mike Fuchs option)
As @Mike Fuchs mentioned, try the following operations:
In menu, Build > Clean Solution
And
In menu, Build > Build Solution
and select the project in question, and click on the refresh button:
Option 2: Clean, Close, Restart and Build (@Pixel option)
As @Pixel mentioned, try the following sequence of operations:
- Clean the solution
- Close Visual Studio
- Open Visual Studio
- Build solution
Option 3: Clear ReSharper cache (@GammaOmega option)
If you have ReSharper, try emptying the ReSharper cache:
In menu, ReSharper > Options > Environment > General > Clear Caches
and disabling and re-enabling ReSharper:
In menu, Tools > Options > ReSharper > General > Suspend / Restore
Option 4: Delete the .suo file (@Neolisk option)
As @Neolisk mentioned, deleting the .suo file might solve your problem. For Visual Studio 2015, the file is located in:
[Path of Solution]/.vs/[Solution Name]/v14/.suo
And for Visual Studio 2017:
[Path of Solution]/.vs/[Solution Name]/v15/.suo
Note that the .vs directory is hidden.
Option 5: Unload and Reload Project (@TTT option)
As @TTT mentioned, try unloading the project that causes problems:
In Solution Explorer, right-click on project, Unload Project.
And re-loading it
In Solution Explorer, right-click on project, Reload Project.
Option 6: Remove and add Microsoft.CSharp reference (@Guilherme option)
As @Guilherme mentioned, try removing and adding the reference to «Microsoft.CSharp» from the projects that have problems.
In Solution Explorer, expand the project, expand «References», right-click on «Microsoft.CSharp» and Remove.
Then, right-click on References > Add Reference, select «Microsoft.CSharp» from the list and click OK
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?
Karel Kral
5,2466 gold badges39 silver badges50 bronze badges
asked Aug 11, 2015 at 13:49
8
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:
.vsSolutionNamev14.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 .vsSolutionNamev15.suo
VS2019 still has this issue. Delete .vsSolutionNamev17.suo
If deleting .suo
still does solve your problem, then delete also all bin
and obj
directories in every project in the solution.
answered Nov 2, 2015 at 12:30
Karel KralKarel Kral
5,2466 gold badges39 silver badges50 bronze badges
9
Also had this problem with a migrated project, so I referenced the Microsoft.CSharp dll. In some projects I needed to remove and add again the Reference in the project.
answered Sep 15, 2015 at 12:40
7
Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me
- Perform Clean Solution
- Close VS
- Delete .suo file & Delete bin/obj directories
- Reopen VS
answered Apr 1, 2017 at 21:24
NarenNaren
79713 silver badges12 bronze badges
2
Similar problem as others, but different resolution. Posting in case I can help someone else.
Running Visual Studio 2017 15.5.2. I use Git and frequently switch branches. Several weeks ago, I started having editors show me errors (all related to types it could not find even though references were valid). Compile worked great. I confirmed the same issue in VS 2017 15.6 Preview (Jan 6, 2018). I would try to delete cache, SUO files, or bin/obj folders and no impact. At first it would appear to work. Reopen Visual Studio and everything would look good. Use «Rebuild Solution» and the IntelliSense errors would returns. I even tried uninstall/reinstall of Visual Studio.
I had the same issue on two machines, both with same version of Visual Studio.
By looking at the errors about missing types, they all appeared to come from two referenced projects. One of those references was a shared project used by just about every other project in the solution, but one of them was a small project without many references. It just so happens that the small project was also referenced by my larger shared project. In Visual Studio, I unloaded the small project and reloaded it. The errors went away! They errors did not come back on Rebuild Solution.
I then switched Git branches and the errors all came back. Fortunately I repeated the above steps of unloading/reloading the small project and the errors went away.
Every time I switch Git branches, the errors come back until I repeat that process. There are zero changes between the Git branches for the smaller project that I unload/reload. Unclear why that sequence is fixing my issue.
answered Jan 6, 2018 at 17:39
HgCoderHgCoder
1,2439 silver badges14 bronze badges
2
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.
answered Sep 15, 2015 at 20:55
SteinStein
1,51923 silver badges30 bronze badges
Visual Studio 2017
I have deleted «.suo» file from location .vsSolutionNamev15.suo
And then restarted Visual studio. This worked for me.
answered Sep 10, 2018 at 14:46
Saurabh RaootSaurabh Raoot
1,2433 gold badges25 silver badges31 bronze badges
Today I’ve had similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but suddenly I’ve noticed that stdafx.h of the project i had problems with doesn’t contain any standard library headers. I’ve speculated that inclusion of all standard headers used in the project in stdafx.h might boost up compilation speed, however doing so fixed Intellisense errors as well.
answered Jan 22, 2017 at 19:40
Minor ThreatMinor Threat
2,0251 gold badge18 silver badges31 bronze badges
In Visual Studio 2019 the problem is with changing branches with Git when there are NuGet packages installed in the project. What I did to solve this:
- Clean Solution
- Close Visual Studio
- Delete the packages folder
- Open Visual Studio
- Go to Package Manager
- Restore all packages
- Recompile
- If roslyn is missing, close and open Visual Studio, then recompile.
answered Mar 16, 2020 at 15:28
Daniel LoboDaniel Lobo
2,1441 gold badge13 silver badges6 bronze badges
I had multiple stdfax.h
in Additional Include Directories. Make sure the stdafx.h
you intended is first in your path.
answered May 30, 2017 at 14:56
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.
answered Mar 13, 2018 at 7:34
FabianFabian
1,04010 silver badges14 bronze badges
I was seeing the intellisearch errors only when publishing a website. (ASP/C# site, VS 2017). They broke the publish. Site ran fine locally.
Cleared the errors by unchecking the setting to pre-compile, and it published fine.
Publish -> Setting -> File Publish Options -> Precompile during publishing
answered May 10, 2018 at 18:02
RahnRahn
5085 silver badges11 bronze badges
I had this issue with a reference to another project. Removing and re-adding the project reference worked for me.
answered Oct 8, 2021 at 18:50
ChrisChris
2,1471 gold badge24 silver badges36 bronze badges
0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
|
1 |
|
05.06.2015, 16:55. Показов 7764. Ответов 14
Почему Visual Studio показывает ошибку в том месте, где ее нет?
__________________ 0 |
45 / 42 / 48 Регистрация: 13.05.2015 Сообщений: 222 |
|
05.06.2015, 16:57 |
2 |
Можно немножко побольше подробностей и конкретики? 0 |
Don’t worry, be happy 17777 / 10542 / 2034 Регистрация: 27.09.2012 Сообщений: 26,510 Записей в блоге: 1 |
|
05.06.2015, 16:57 |
3 |
В большинстве случаев по той причине, что ошибка есть 0 |
Gangsta 0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
||||
05.06.2015, 16:59 [ТС] |
4 |
|||
Например
Здесь ошибка. Max(i, l) подчеркивает красной линией. А программа компилируется без ошибок 0 |
45 / 42 / 48 Регистрация: 13.05.2015 Сообщений: 222 |
|
05.06.2015, 16:59 |
5 |
Скорее всего это не баг, а фича 1 |
25 / 11 / 5 Регистрация: 11.01.2014 Сообщений: 85 |
|
05.06.2015, 17:00 |
6 |
Потому что твой Max уже существует в STL. 0 |
45 / 42 / 48 Регистрация: 13.05.2015 Сообщений: 222 |
|
05.06.2015, 17:03 |
7 |
Не компилится в VS 2008: Построение
1>Компиляция… 0 |
0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
|
05.06.2015, 17:06 [ТС] |
8 |
Скорее всего это не баг, а фича ну да В STL вроде бы нет Max. using namespace std; я не пишу Добавлено через 1 минуту
Не компилится в VS 2008: А у меня VS 2010 0 |
0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
|
05.06.2015, 17:12 [ТС] |
9 |
скрин Миниатюры
0 |
0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
|
05.06.2015, 17:12 [ТС] |
10 |
никто не знает? 0 |
Don’t worry, be happy 17777 / 10542 / 2034 Регистрация: 27.09.2012 Сообщений: 26,510 Записей в блоге: 1 |
|
05.06.2015, 17:16 |
11 |
Сообщение было отмечено Gangsta как решение РешениеВозможно из-за того, что в десятой студии фиговая поддержка 11-ого стандарта. Проверьте на VS2013 1 |
Dimension 591 / 459 / 223 Регистрация: 08.04.2014 Сообщений: 1,710 |
|
05.06.2015, 17:20 |
12 |
Проверьте на VS2013 запустил у себя ,норм все 1 |
0 / 0 / 0 Регистрация: 30.05.2015 Сообщений: 15 |
|
05.06.2015, 17:24 [ТС] |
13 |
Понятно. Надо Visual Studio менять 0 |
45 / 42 / 48 Регистрация: 13.05.2015 Сообщений: 222 |
|
05.06.2015, 17:25 |
14 |
Gangsta, можете попробовать совершенно другую IDE 1 |
43 / 43 / 12 Регистрация: 06.10.2014 Сообщений: 135 |
|
05.06.2015, 17:26 |
15 |
…подчеркивает красной линией. Замечал подобное и в VS2013 когда проект большой и/или открыто много файлов в редакторе. Иногда проходило само собой. Иногда после закрытия/открытия. 1 |
I’m having strange issues with Visual Studios 2015 Enterprise Edition and I couldn’t find solution online. I need to build a solution file that contains multiple sub-projects and solutions. I had created my own project and a solution within the main solution. When I build the main solution, build fails without Visual Studio showing any errors unless I changed the setting in one of the dropdown boxes from «Build+Intellisense» to «Build Only» (It’s one of those dropdown boxes in Error List window ). With «Build Only» setting, I can see several errors and they are all from my project. But majority of them don’t seem to apply anymore since I have fixed them. For instance, one error is invalid namespace and I received this error from not adding the reference assembly the namespace is declared. Since the reference is already added, I’m not sure why Visual Studio is still listing this error. Do I need to clear cache or something? I’ve tried cleaning the solution.
asked Aug 17, 2016 at 12:31
Ok, So I decided to go through all warnings and found out that some assemblies are built with higher .Net framework version (4.6.1) than my project (4.5.1). So I changed the Target framework of my project to 4.6.1. Voila, no more errors! For reference purpose, Target framework option is under project property.
answered Aug 17, 2016 at 13:24
KMCKMC
1,6413 gold badges24 silver badges53 bronze badges
I’m having strange issues with Visual Studios 2015 Enterprise Edition and I couldn’t find solution online. I need to build a solution file that contains multiple sub-projects and solutions. I had created my own project and a solution within the main solution. When I build the main solution, build fails without Visual Studio showing any errors unless I changed the setting in one of the dropdown boxes from «Build+Intellisense» to «Build Only» (It’s one of those dropdown boxes in Error List window ). With «Build Only» setting, I can see several errors and they are all from my project. But majority of them don’t seem to apply anymore since I have fixed them. For instance, one error is invalid namespace and I received this error from not adding the reference assembly the namespace is declared. Since the reference is already added, I’m not sure why Visual Studio is still listing this error. Do I need to clear cache or something? I’ve tried cleaning the solution.
asked Aug 17, 2016 at 12:31
Ok, So I decided to go through all warnings and found out that some assemblies are built with higher .Net framework version (4.6.1) than my project (4.5.1). So I changed the Target framework of my project to 4.6.1. Voila, no more errors! For reference purpose, Target framework option is under project property.
answered Aug 17, 2016 at 13:24
KMCKMC
1,6413 gold badges24 silver badges53 bronze badges
Здесь коллекция популярных ответов. Upvote ОП ответа, если он помог вам:
Вариант 1. Очистка, сборка и обновление (опция @Mike Fuchs)
Как упомянул @Mike Fuchs, попробуйте следующие операции:
В меню «Построение»> «Чистое решение».
А также
В меню Build> Build Solution
и выберите проект, о котором идет речь, и нажмите кнопку обновления:
Вариант 2: очистить, закрыть, перезапустить и построить (опция @Pixel)
Как упоминалось @Pixel, попробуйте следующую последовательность операций:
- Чистый раствор
- Закрыть Visual Studio
- Откройте Visual Studio
- Построить решение
Вариант 3: очистить кеш ReSharper (опция @CydrickT)
Если у вас есть ReSharper, попробуйте очистить кеш ReSharper:
В меню ReSharper> Параметры> Среда> Общие> Очистить кэш
и отключение и повторное включение ReSharper:
В меню Инструменты> Параметры> ReSharper> Общие> Приостановить/Восстановить
Вариант 4. Удалите файл .suo (опция @Neolisk).
Как уже упоминалось @Neolisk, удаление файла .suo может решить вашу проблему. Для Visual Studio 2015 файл находится в:
[Путь решения]/. Vs/[Имя решения]/v14/.suo
И для Visual Studio 2017:
[Путь решения]/. Vs/[Имя решения]/v15/.suo
Обратите внимание, что каталог .vs скрыт.
Вариант 5: выгрузить и перезагрузить проект (опция @TTT)
Как упоминалось в @TTT, попробуйте выгрузить проект, который вызывает проблемы:
В обозревателе решений щелкните правой кнопкой мыши проект «Выгрузить проект».
И перезагрузить его
В обозревателе решений щелкните правой кнопкой мыши проект «Перезагрузить проект».
Вариант 6: удалить и добавить ссылку на Microsoft.CSharp (опция @Guilherme)
Как упомянул @Guilherme, попробуйте удалить и добавить ссылку на «Microsoft.CSharp» из проектов, в которых есть проблемы.
В обозревателе решений разверните проект, разверните «Ссылки», щелкните правой кнопкой мыши «Microsoft.CSharp» и выберите «Удалить».
Затем щелкните правой кнопкой мыши References> Add Reference, выберите «Microsoft.CSharp» из списка и нажмите «OK».
It’s always fun when Visual Studio (ie @drunkvs) can’t recite the alphabet backwards: The code below builds just fine when running through the compiler, but Visual Studio displays Intellisense errors in the Error Window and in the code with underlined squiggles:
The actual build of the code succeeds, but Intellisense is flagging several classes as missing even though they clearly exist and clearly compile properly.
IntelliSense is High!
So IntelliSense sometimes goes off the rails and if you see errors in your project that don’t make sense, first check to see if the errors are related to Intellisense.
Notice the drop down in the error list that lets you see Build + Intellisense which, in the case above produces 3 errors, but no errors if I just show Build Only:
Note the Intellisense error drop down is a new feature so you may not see it in older versions of Visual Studio. Not sure when it arrived but it was in one of the late VS 2015.x updates.
Clearing up Intellisense
There’s usually a simple solution when IntelliSense decides to sleep one off:
Delete the .vs
folder
The .vs
folder holds solution related temp data including the .suo
file that caches intellisense and some debug data. That folder also holds Web site configuration data for Web projects and a few other things. It’s safe to delete this folder — Visual Studio recreates it when it’s missing.
Older versions of Visual Studio (prior to VS 2015) didn’t have a separate folder and dumped that same information into files in the solution’s root folder.
In these older versions you can fix Intellisense issues by deleting the Solution’s .suo
file. Deleting the .vs
folder in newer version nukes the .suo
file which is responsible for cached IntelliSense and also some cached Debug data. When VS acts up and reports whacky errors that seem wrong, the burning down the .suo
file is a nice quick thing to try first.
To do this:
- Shut down VS
- Nuke the
.vs
folder or the.suo
file - Restart VS
The .suo
file contains cached IntelliSense data and once that file is off, no amount of recompilation or clearing the project is going to help. Nuke the .suo
file. or in VS 2015 or later the .vs
folder and get back to sanity.
Compiler Errors?
I haven’t run into this problem very frequently but when it does happen it’s usually quite vexing resulting (for me at least) in a flurry of deleting output folders.
I have a standard set of steps I tend to go through when I get compiler errors that are wrong. Well, usually it’s me who’s wrong, not the compiler but on occasion I get to be right and the compiler is really wrong.
If you have errors that show under the Build Only
dropdown, then the issue isn’t Intellisense.
This has gotten a lot better, but for a while invalid compiler errors were a big problem with the .NET SDK projects (.NET Core / .NET Standard) and in those cases the solution for me usually is (and still occasionally is):
- Delete the
obj
folder completely - Delete the
bin
folder completely
While Visual Studio’s Clean
project feature is supposed to address this, Clean will only clean up files the project knows about. If you’ve removed or renamed assemblies there may still be left over files in project output folders and deleting them cleans out the project completely.
This often fixes odd left over file issues that can cause strange compilation behavior. I never really considered Intellisense failure previously because Visual Studio didn’t differentiate compiler and IntelliSense Errors (or more accruately I didn’t notice the dropdown). I’d see errors in the Error list, yet my project would compile successfully, which was even more confusing.
Back to the Straight And Narrow
It’s nice that Visual Studio now explicitly shows these errors separately as Build and Intellisense errors, so you can take the sepearate actions to clean up this mess. In the past when the errors weren’t separated it was even more confusing with compiles succeeding, but the error list showing errors.
Now as to the cause of any of these errors? @drunkvs has some cleaning up to do after the barf fest of the previous night…
It’s always fun when Visual Studio (ie @drunkvs) can’t recite the alphabet backwards: The code below builds just fine when running through the compiler, but Visual Studio displays Intellisense errors in the Error Window and in the code with underlined squiggles:
The actual build of the code succeeds, but Intellisense is flagging several classes as missing even though they clearly exist and clearly compile properly.
IntelliSense is High!
So IntelliSense sometimes goes off the rails and if you see errors in your project that don’t make sense, first check to see if the errors are related to Intellisense.
Notice the drop down in the error list that lets you see Build + Intellisense which, in the case above produces 3 errors, but no errors if I just show Build Only:
Note the Intellisense error drop down is a new feature so you may not see it in older versions of Visual Studio. Not sure when it arrived but it was in one of the late VS 2015.x updates.
Clearing up Intellisense
There’s usually a simple solution when IntelliSense decides to sleep one off:
Delete the .vs
folder
The .vs
folder holds solution related temp data including the .suo
file that caches intellisense and some debug data. That folder also holds Web site configuration data for Web projects and a few other things. It’s safe to delete this folder — Visual Studio recreates it when it’s missing.
Older versions of Visual Studio (prior to VS 2015) didn’t have a separate folder and dumped that same information into files in the solution’s root folder.
In these older versions you can fix Intellisense issues by deleting the Solution’s .suo
file. Deleting the .vs
folder in newer version nukes the .suo
file which is responsible for cached IntelliSense and also some cached Debug data. When VS acts up and reports whacky errors that seem wrong, the burning down the .suo
file is a nice quick thing to try first.
To do this:
- Shut down VS
- Nuke the
.vs
folder or the.suo
file - Restart VS
The .suo
file contains cached IntelliSense data and once that file is off, no amount of recompilation or clearing the project is going to help. Nuke the .suo
file. or in VS 2015 or later the .vs
folder and get back to sanity.
Compiler Errors?
I haven’t run into this problem very frequently but when it does happen it’s usually quite vexing resulting (for me at least) in a flurry of deleting output folders.
I have a standard set of steps I tend to go through when I get compiler errors that are wrong. Well, usually it’s me who’s wrong, not the compiler but on occasion I get to be right and the compiler is really wrong.
If you have errors that show under the Build Only
dropdown, then the issue isn’t Intellisense.
This has gotten a lot better, but for a while invalid compiler errors were a big problem with the .NET SDK projects (.NET Core / .NET Standard) and in those cases the solution for me usually is (and still occasionally is):
- Delete the
obj
folder completely - Delete the
bin
folder completely
While Visual Studio’s Clean
project feature is supposed to address this, Clean will only clean up files the project knows about. If you’ve removed or renamed assemblies there may still be left over files in project output folders and deleting them cleans out the project completely.
This often fixes odd left over file issues that can cause strange compilation behavior. I never really considered Intellisense failure previously because Visual Studio didn’t differentiate compiler and IntelliSense Errors (or more accruately I didn’t notice the dropdown). I’d see errors in the Error list, yet my project would compile successfully, which was even more confusing.
Back to the Straight And Narrow
It’s nice that Visual Studio now explicitly shows these errors separately as Build and Intellisense errors, so you can take the sepearate actions to clean up this mess. In the past when the errors weren’t separated it was even more confusing with compiles succeeding, but the error list showing errors.
Now as to the cause of any of these errors? @drunkvs has some cleaning up to do after the barf fest of the previous night…