All lines in Visual Studio are squiggly red - c#

I'm sure this question has been asked before, if there's a similar question with a solution I apologize in advance. I've tried to find something similar to this in the forum already but I can't find any solutions.
So I recently swapped to a new computer. I installed Visual Studio, same version as I used previously, and I also installed .NET 7 (which I used previously aswell).
I started my project in Visual Studio and everything in my code is squiggly red. Literally everything, except the names of variables. It can't find any of the namespaces, not even System. I've tried going through the settings, re-installing NuGet packages, removing bin folders, removing packages folder etc. I can't seem to find the issue, afaik there's no major difference between my old laptop and the one I'm currently using. It's the exact same project files. The files work on my old laptop.
Not sure if I've missed something really obvious. Very thankful for any help.
Some images to showcase the error:

So, seemingly after attempting everything I could find online (including the steps below), I attempted this with success:
Clean solution
Restart Visual Studio
Remove packages folder
Restore NuGet packages.
Rebuild solution
Repeat around 10 times.
If anyone has this issue and can't get it to work, just keep repeating the steps. I had to do it over 10 times before it actually worked. I'm still not sure what caused it but this was my solution.

Related

Visual studio 2019 go to definition and Intellisense not working

I have noticed a weird issue with Visual Studio 2019 v16.0.1 the IntelliSense about "Using directive is unnecessary" normally grey is missing and type reference suggestion for missing using is not working.
I also tried with Visual Studio 2019 Preview but no luck.
I have tried the following:
deleted .vs folder and restarted.
Reinstalled Visual Studio
Reset settings via import and export setting under tools
Any other suggestions will be appreciated.
Close Visual Studio
Delete .vs folder (it is a hidden folder inside the folder which contains the solution *.sln)
Start Visual Studio
Solved my problem
Update From the comments
Deleting Browse.VC.db file within .vs folder worked for me. I did this to avoid deleting .suo which has information I want to preserve
NOTE 1: I am using Visual Studio 2019, but it may work on other versions
NOTE 2: This did not solve the OP problem, but it is a good candidate to solve your
Go to Tools -> Options -> Text Editor -> All Languages -> General. Make sure “Auto List Members” is checked. Also, make sure “Parameter Information” is checked.
If you are facing this issue with Unity projects then,
Check in your Unity settings whether it has Visual Studio configured as the external editor.
Click on Regenarate project files in the Unity settings.
Go to Assets => Open C# project.
This will restart Visual Studio with your project.
In my case, Resharper is the culprit. Disabling it immediately solved the issue.
I think these issues are discussed here and are resolved by an update and some worksrounds are bring discussed:
https://developercommunity.visualstudio.com/content/problem/505489/cannot-navigate-to-the-symbol-under-the-caret-3.html
For anyone who are searching for another suggestion, I just go throught this issue, as OP said, I've deleted .vs folder, I've update vs to last version, I've uninstalled and reinstalled vs to the last version, I've reset settings, delete all obj folders, I've installed Microsoft.Net.Compilers but nothing worked, at the end I just remembered that sometimes the projects required WindowsBase library, until now I don't know why, but after adding that dll Intellisense started to function again.
I use resharper (vs 2017) but had not installed it on 2019. After installing Resharper on 2019 the intellisense started working again. (yes, it was working in 2019, then stopped)
I don't have an explanation on why this would fix it. Just did for me.
First time I use VS 2019, I need to manually install Code Analysis. Make sure it is installed at your project properties.
And today, for the new class, the suggestion or namespaces not showing for VS 2019 Intellisense, and Go to Definition not working too.
I must do close solution, and re-open and VS 2019 doing scanning while opening project, and then worked again.
I think this is bug for VS 2019. Try to close solution and re-open it.
I have tried almost all the solution mentioned above but it doesn't helped me. Trying to restart my PC solved my problem.
I tried lots of things but nothing worked for me until I found this post. He mentions a few things I have already tried that didn't work, but his final solution worked for me...
At the root of our solution there is a packages folder. I deleted the
entire contents of this folder. Upon reopening Visual Studio,
Intellisense and Go To Definition were restored to full working order.
close visual stdio
For mac in your folder: do command + shift+ .
you will see hidden files -> delete .vs folder
open solution again
After working for a few months, Intellisense suddenly stopped. This cost me a lot of lost time! I've been worked with Visual Studio for about 10 years, and this problem happens occasionally in every version.
Here's what I tried for this iteration of the problem:
Closing Visual Studio and re-opening does sometimes make the problem disappear for a short time, but it certainly doesn't solve it
Likewise restarting my laptop
Installing the latest Visual Studio 2019 update didn't help (I'm on 16.8.3 now if anyone's interested)
Deleting the hidden .vs folder doesn't seem to solve anything (doing so also means you lose your current window layout, as well as any bookmarks you've set)
Unticking the Track Changes option in this menu: Tools-> Options-> Text Editor-> General.
I've updated my NuGet reference to the Microsoft.Net.Compilers library to the latest stable version, as suggested here, but sadly this made no difference
I thought I've finally solved the problem by following the advice from Homer. I deleted the packages folder at the base level of my project (somewhat nervously, as I wasn't sure if it was needed), and thought it had solved the problem, but no such luck.
However, one thing to watch out for - after doing this, Visual Studio recognised my classes but no longer recognised built-in ones (all the referenced namespaces at the top of my controllers were underlined in red). I then deleted the .vs folder (again), which seemed to solve the problem.
When I recompiled my solution, it gave a few CS0433 compilation errors with duplicate namespaces for the MinLength and MaxLength directives in some identity user name and password validation code. I got round this by removing the Microsoft.EntityFramework Nuget library (I had to also remove Microsoft.AspNet.Identity.EntityFramework too, since this depended on it), then adding them both back in, making sure to include at least version 6.2 of the former (otherwise I got another runtime error to do with the FirstOrDefaultAsync method called somewhere!).
My current situation: all existing Intellisense is working, but it's not recognising new classes I add unless I exit Visual Studio and go back in again. May have to live with this ... unless anyone can help me?
I've got that problem today with only one project. I got no Intellisense warnings (i.e. naming styles, "Variable not referenced", etc..) for files in that project. Not in VS 2017 Pro nor in VS 2019 Community.
Check, if your Project->Build->"Warning level" is set to 0...
If you have Visual Studio 2017 installed side-by-side with Visual Studio 2019, close VS2019, open the project in VS2017, wait until it is fully loaded, then close VS2017, and reopen VS2019 - fixed!
There must be a bug in the VS2019 intellisense stuff, but VS2017 seems to fix it with no need to keep deleting the .vs directory.

Can't Publish Because of Intellisense Errors

In VS 2015, I have a solution that builds and debugs just fine. But, when I go to publish it, it won't let me because of 60 intellisense errors.
I've found a few threads like these:
Visual Studio 2015: Intellisense errors but solution compiles
Intellisense keeps showing errors while build is successful Visual Studio 2015
I've tried all the answers & suggestion, even in the comments.
What I've tried:
Go into the references of every project in the solution. Remove the reference to C#, and to all of the other projects. Clean. Rebuild (which of course failed.) Then add them all back. Clean. Rebuild.
Delete every .suo file within the solution. Clean. Rebuild.
Delete all of the bin and obj folders within the solution. Clean. Rebuild.
Do all of the above, but wait to do a clean and rebuild until all three steps had been done. Then clean & rebuild.
Updated every nuget package in the solution to the newest version.
Anyone else ever seen this and found a fix?
UPDATE:
The 60 errors are all over the place. Here's just a sample:
This question is getting a lot of views, and some stars. So I thought I would circle back to it and post the solution I found.
It turns out that my issue centered on TypeScript. Another developer had installed in on this solution while using Visual Studio 2017. And when I tried to publish using Visual Studio 2015, it kept throwing the Intellisense errors and would not let me publish.
The only way we figured out how to get around this was for me to upgrade to VS 2017. (I intended to anyway, but this just hurried the process up a little.) Once the upgrade was complete, the Intellisense errors went away and I was able to publish.
I hope this helps other people.

Visual Studio (xamarin) hanging on every build, clean, or rebuild with AAPT.exe running in the background while it does this

I've been banging my head against the wall for the last few days trying to figure this out.
Here is whats happening:
Anytime I open the project VS hangs responding every once in a while for a click I made a minute or so before. While you watch task manager you see that AAPT.exe is popping up every few seconds and running for a moment, after about 3-5 minutes it completes whatever it is doing and vs starts working again until I do one of the other things that sets it off.
Same thing when I clean the project.
Same thing when I build/rebuild the project.
When debugging to a physical device it will build and deploy to the device, then hang with the same issue for a few minutes before starting the debug
What I have discovered:
This issue could possibly be related to this bug report https://bugzilla.xamarin.com/show_bug.cgi?id=43081 however following the instructions provided on that don't help and only cause more errors.
It seems that aapt is crunching my pngs and that is causing the hang, however I only have a few small icons in terms of images in the entire project, nothing that should take 2-3 minutes to compress.
What I have tried:
Update all android sdks and resources to the latest available.
Update java(64bit) and removed all other instances of it besides the newest one
Removed and reinstalled all android resources.
Repaired Visual Studio(community 2015)
Nuked VS with https://github.com/Microsoft/VisualStudioUninstaller/releases
Attempted to install VS 2017 community however it never functioned with the error CLR20r3 from mscorlib 4.6.1 with the error being 'remoteHostService.servicehub.service.json' could not be found(I checked it existed where it should be, and it referenced VsixServiceDiscovery: A procedure imported by 'Microsoft.VisualStudio.Settings.15.0.dll' could not be loaded. (I unfortunately dont have the full trace anymore I got rid of 17)
After all that I reinstalled vs 15, which I got working(barely) but it still has the exact same issue as when I started.
At this point my next step is to nuke my computer completely, which I don't really want to do, so I'm desperately hoping that someone knows how to fix this.
So after playing with a few things I noticed that a decent portion of the packages from NuGet in my solution had a triangle on them, for not having the reference.
Ultimately what I've figured out is that after each of the events that I described above, AAPT was actually redownloading every single one of the ~20 packages that I have in my solution because for some reason it had failed to link the project to the local copies despite being there.
The solution was discovered on this thread:
https://forums.xamarin.com/discussion/89926/the-referenced-component-xamarin-android-support-xxx-could-not-be-found-after-upgrade-with-nuget
Ronald Peters
February 23
I fixed the yellow marks by forcing reinstall of packages: open NuGet Package Manager Console and execute "Update-Package –reinstall".
This forced all packages to remove all references from the project and reinstall themselves. Which ultimately most of them just found the local copy and just needed to be linked again.
After running this, VS no longer hangs after any of the events listed above, and everything seems to be working again.

Visual Studio 2015 Community - All References Broken

I just installed VS2015 community on my home machines. On my laptop, it works great. However I've run into an odd issue on my desktop. No matter what the reference is, it displays as unable to find (yellow warning symbol). It doesn't matter what or where it is. I have tried adding framework references (As basic as System) and references to external API DLLs in the local directory like Protobuf. NuGet will download packages referenced by projects I am working on and they will also be marked invalid. The properties for these references does not include a path, even when I specify one.
I'm a develop at work so I understand how to handle these issues generally. I've tried deleting the references and re-adding them, creating new solutions from scratch, pretty much everything I can think of and I'm out of ideas.
This is a Win7 machine with .NET 4.6.1 installed. I have tried changing my projects to target framework of 2,4,4.5,4.6, and 4.6.1 (no difference). This is a C# project if it matters.
Can anyone recommend next steps? Thank you.
I found the issue. Last month I tried to upgrade to Win10 and it didn't work out for me so I rolled it back. It deleted all the ACL information on all my directories. Specifically, the access to Microsoft.CSharp.Targets was lost. I restored that and everything worked again. Of course, now I have to try and fix every file and directory on my computer so I have access again. Thanks, Win10!

Web Project Templates Missing

I've installed the VS Community 2015 Update 1 but I'm not able to see the Web Project templates. I have done everything, reinstall, repair, reinstall the templates using devenv /installvstemplates, remove the ProjectTemplatesCache folder, pretty much everything I've found about similar issues but without results.
Any suggestion?
Thanks in advance
Well, the only thing that actually solved this issue: uninstall every single component manually installed (I assume that restoring the system to a previous point should work as well)...

Categories