VS Solution Explorer Analyzers exclamation: ef1000 "possible sql injection vulnerability" - visual-studio

Strange message in Solution Explorer.
ef1000 "possible sql injection vulnerability"
It doesn't prevent compile, no errors, no warnings, no messages in "Errors List".
No similar messages in the output on compile...
Click doesn't move focus to "vulnerability" line. No referenced file/line related information.
But there is context menu with "Delete" button which doesn't work (nothing happens). There are no Analyzers related entries in proj file.
Looks like common package references bug. How to fix it?

I went to that location C:\Users\User.nuget .. etc and deleted the package. I closed visual studio and reopened it. The package was restored and the error was gone. I was using a .net framework application in visual studio at the same time and was opening and closing the core solution repeatedly so I'm thinking the package got corrupted somehow.

Just unload the project and reload it again, the warning is disappeared.
The source
UPDATE for Visual Studio 2019:
If you use Visual Studio 2019 you have always to get last version. So if there are any updates available just install it.
Click on Help => Check for Updates => Update.

Related

Visual Studio 13 raises unknown error at the startup?

As I start visual studio 13 it raises unknown error by saying "Microsoft Visual Studio 2014 has stop working" without any further explanation.
Here's what I've tried to solve this problem;
I reinstall .Net framework
I repair, uninstall-install Visual Studio
2013
I installed another version of VS13
but still the problem persists. Do you have any further suggestion ?
I am using Windows 8.
I've run into a similar situation described here. Once i find a solution, i will post it there.
As a first attempt i would try to generate a logfile via the /log option and see if there is a problematic extension that you could disable/deinstall, e.g. NuGet.
You say you reinstalled VS2013, so the problem might be related to settings. If reverting all settings is an option for you, see this thread on how to truly really reset your settings. This involves calling your devenv.exe with special parameters (e.g. in a cmd.exe), removing files and tinkering with the registry.
I have found the solution to this or a similar problem if you are starting Visual Studio by loading a solution file.
The symptoms are that a solution that previously could be loaded with no problems, suddenly starts having the unknown error box appear for every project in the solution. Sometimes you can't see the relationship to the continuous reappearance of the error message and the project loading, because you don't have the solution explorer open, so you aren't even aware there is a correlation.
The solution to this is to use task manager to stop visual studio, confirm with visual studio that you wish to shut it down and then look for the .suo file for the solution you are trying to load. In VS2012 it appears in the same directory as the solution file and has the extension solutionname.v11.suo while in VS2015 it appears in a hidden .vs directory under the location where the solution file is found, in a folder named for the solution.
Delete this file and the problem will go away.
The .suo file contains the user preferences for the solution you are trying to load and it is perfectly safe to delete it as it is regenerated when you load the solution.
If you are getting the unknown error when you haven't tried to load any solutions, this is probably not the right answer.

Double Click in Visual Studio 2013 Update 3 Solution Explorer Not Working

Until quite recently it was possible to click on a method in the VS 2013 Solution Explorer and have the method appear in the code window. That does not appear to be working anymore. Any idea of how to enable this functionality? It was quite useful. For example, in the Solution Explorer view below, clicking on either addBlanks or formatSql would move the code window to the method in question.
It turns out that I have more information about this problem. I completely uninstalled VS 2013 Pro and reinstalled it. Somewhat predictably the problem went away... However, I was getting an error message about the NuGet package manager not being properly installed. To fix this I removed and reinstalled the NuGet package manager. That did resolve the NuGet error message, but the problem with clicking on methods in the Solution Explorer came back. Finally I removed and reinstalled VS 2013 Pro yet another time and now clicking on methods in the Solution Explorer works correctly.
Somehow the original problem reflects some combination of VS 2013 Pro, NuGet, etc.
It is still possible to quickly display a source code file. I am using Visual Studio 2013 Express Update 3.
It might make a difference to highlight/activate the right-most code preview symbol in the Solution Explorer panel:
It is located to the right of the properties screw-wrench symbol.
If this symbol is active, a single click on a file name is sufficient to get the file displayed in the code view. The same applies to methods. Double-click also works, when the preview symbol is not highlighted.
This turned out to be a bug in Visual Studio 2013 Pro Update 3 (and perhaps other versions). Microsoft recognized this bug and has fixed it in VS 2013 Pro Update 4. See https://connect.microsoft.com/VisualStudio/feedback/details/1001072/double-click-in-visual-studio-2013-update-3-solution-explorer-not-working for a discussion and Microsoft's resolution.

CodeLens not showing references

CodeLens stopped working for some reason in project solution that I'm dealing nowadays. It is not showing references instead "- references". However, when I open up Visual Studio with another project It works like charm.I can confirm that CodeLens is enabled. Do you have any idea to make it work?
My Solution:
Toggle the CodeLens feature off and then on again.
Note: Many have found the feature to be turned off after an update so you just need to turn it back on. Thanks to #razblack for calling this out. Don't forget to give his comment an upvote if this was your issue!
Go into Tools -> Options... -> Text Editor -> All Languages -> CodeLens.
Uncheck "Enable CodeLens" option and click OK.
Go back into Tools -> Options... -> Text Editor -> All Languages -> CodeLens.
Check the "Enable CodeLens" option and click OK.
Note: I've fixed the issue once before by closing the problem .cs file and then reopening it. Closing any referenced files may also be required.
My Problem(s):
Similar to the original poster, CodeLens stopped refreshing references after I made a bunch of refactors. I was seeing stale references to code that didn't exist and I was also seeing the "- references" issue as described in the original post.
My Environment & Specific Scenario:
Visual Studio 2015 with Service Pack 2 and Resharper Ultimate 10.0.1
I was doing a major overhaul with a ton of refactoring and my project wasn't compilable for an hour or so. Once I could compile the project again, the references weren't working.
Same problem here.
CodeLens works normally with small solutions, but not working with large ones.
And this behavior is accompanied with crash of Alm.Shared.Remoting.RemoteContainer.dll process.
Tried in VS 2013 Update 4 and VS 2013 Update 5 RC.
Solution:
Close all programs and clean %LocalAppData%\Temp folder (or maybe just ALM folder inside it).
A simple solution, which works!
I did try enabling CodeLens in Visual Studio (2015) -->
Quick Launch (Ctrl+Q)
Options (CodeLens)
But, it was enabled :( Then, it did work with: (Closing the programs),
Win+R --> %temp% EnterDelete all
For me, CodeLens was disabled, so make sure it is still enabled.
I know it is an easy answer, but it might help some developers.
Go to Tools -> Options -> Text Editor -> All Languages -> CodeLens then click the "Enable CodeLens" option if it is not checked and then save it.
It looks like VS disabled it for some reason, maybe after an update or slow startup.
Try to remove .suo file which is storing some enviroment/solution settings. This helped me.
Just had this problem with VS 2019.
I tried disabling / enabling codelens and it didn't work.
I deleted the .suo after that and it didn't work.
I tried disabling / enabling codelens again (after deleting the .suo) and now it works again.
UPDATE (about 2 weeks later):
It started happening again and this time I disabled IntelliCode in Extensions and all of a sudden Codelens started working again.
UPDATE AGAIN (25 Nov 2019):
I reported this to Microsoft and had a dialog with them. You do not have to turn off all of Intellicode at this time, only disable Intellicode Refactorings in Tools -> Options -> Intellicode. The actual fix is slated for VS 2019 16.4 I believe.
You may have circular references in your solution that prevents CodeLens from working. Some details were provided in the comments for this issue on the Visual Studio Connect site:
Somehow, two of my projects in my solution ended up referencing each
other causing a circular reference. I think it was a by-product of
Resharper's shortcut to reference an undefined class. Once I was
cleaned up all of the references, I'm now getting valid values in my
reference counts.
How did you go about "cleaning" up references?
In my case, my solution has multiple project files. In the references
folder of Project A, there was a reference to Project B. In the
references folder of Project B, there was a reference to Project A.
This was causing the circular reference. If you try to do this
"manually", VS will prompt you with a warning regarding the circular
reference.
To clean this up, I removed the reference to Project B from my Project
A. I had do some minor class definitions in my Project B so everything
would still compile in the end.
I found out that if you block the Visual Studio with the Firewall, the Code Lens did not work.
So unblock it from the firewall to make it work.
Or edit Firewall settings for file:
C:\Windows\Microsoft.NET\assembly\GAC_32\
Microsoft.Alm.Shared.Remoting.RemoteContainer\
v4.0_12.0.0.0__b03f5f7f11d50a3a\
Microsoft.Alm.Shared.Remoting.RemoteContainer.dll
I had this problem with VS2015 that already had "update 1" installed.
The thing was that I originally installed VS2015 with the "custom" setup, not the "default" option, and I accidentally left out the "Git for Windows (3rd party)" option under "Common Tools".
This can be fixed by these steps:
Run the VS2015 setup again (from control panel - uninstall program)
Right click VS2015, select "Change"
On popup screen, select "Modify"
On setup screen, select "Git for Windows (3rd party)"
Move on with the setup, install selected features
In Visual Studio Professional or Enterprise you can enable CodeLens by doing this:
Tools → Options → Text Editor → All Languages → CodeLens->Enable
This is not available in some Community Edition versions
Try deleting .suo file inside of the hidden .vs folder in your project. This worked for me in VS 2017.
My Problem
Always directly after enabling CodeLens, press OK, i see the extra space required for the CodeLens information and than it disappears and when i look at the options again it is diabled. Driving me nuts.
Approaches
Deleting caches/configurations. Clean start without Extensions work. Normal start without ReSharper works. Reinstall ReSharper + deleting cahces -> False behavior
Solution
Unter Extensions - ReSharper - Options - Environment - Performance Guide was "Disable CodeLens for all languages" set to "Fix Silently". Set to Ignore -> WORKS!
hope this helps someone
I had the same problem, but one's of my colleagues who has the same development environment than me, doesn't have it...
The only one difference between our both environment was the quantity of RAM. There is 10GB allocated to his VM, and on mine, there is 6GB allocated. Since I upgraded the quantity of RAM allocated to my VM to 8GB, all my references are shown !
Installing Update 1 for Visual Studio 2015 fixed the problem for me.
Download Update 1
After reading the answer to this Stack Overflow question CodeLens only showing references? I decided my problem with Codelens was I was running Visual Studio 2015 Update 1 but was using Team Foundation Server 2012. I upgraded to TFS 2015, which upgraded in place and didn't require any new settings or URIs to be connected to Visual Studio as before. Then I reloaded my solution - but I still had the issue where it just said "– references" everywhere. I closed Visual Studio, started it again and reloaded my solution and finally I saw the correct reference counts as they used to show.
I found on the new VS 2015 update 3 it happens on a large class in a medium level solution 10+ projects and has nothing to do with circular references, a bad SUO file, or other things. It appears just deleting the temp file location(as mentioned already), closing VS and then reopening and hitting 'ALT+2'(forcing a reference find for Code Lens) made it magically work for me.
It also appears in some solutions and projects Visual Studio will create an old referenced suo file in .vs folder. I don't know the exact rhyme or reason, but it could be created in my case and the CodeLens worked again. It could potentially be a Visual Studio options is somehow referenced in projects under source control. As I know this happened with an older solution I have upgraded many times that was under GitHub control and it does have an .gitignore file(ignore files could change depending on source control). Suffice to say I have had similar things happen with other techs in the past when there is a lock on a source control file that should be updated and won't update. Simple answer is to add to an ignore and delete the settings file.
I have Visual Studio 2017 Professional on Windows 10.
I have observed this under several circumstances:
MicroSoft decided I needed some critical update for Windows and it installed while I was working - causing some of the VS components to crash.
Visual Studio update was received in background.
Some component of Visual Studio crashed - not the VS just some attached feature (did not note exactly which one)
No known cause.
In each of these cases I did in order (sometimes it worked after each of these)
Build / Rebuild solution
Build / Clean Solution
Close and Restart Visual Studio
Remove Symbols cache, restart VS
Close BOTH VS and SSMS and restart them
Close VS and Restart Windows
Close VS, force all pending Windows updates to load, restart Windows
In options, Uncheck Codelens/apply and re-check/apply (OK button)
I tried most of the solutions above without luck, as I also saw this problem. On top, certain newly added classes were showing up as white/black (regular text) in Visual Studio.
Changing to Release typically helped, but wasn't a long-term solution.
However, this helped on both issues - verified on another machine. Maybe some of the steps can be left out.
Close all document tabs
Clean solution
Right click on solution, click "Enable Lightweight Solution Load"
Close solution
Reopen solution
Right click on solution, click "Disable Lightweight Solution Load"
Close solution
Reopen solution
Rebuild
Explicitly enable CodeLens in the workspace settings.json:
// show code lens on editor
"editor.codeLens": true,
Verify that the following properties show on the editor:
// inline count of reference for classes, interfaces, methods, properties,
// and exported objects
"typescript.referencesCodeLens.enabled": true
I could fix my problem with C# CodeLens and Omnisharp.
My C# extension was 1.25.0.
What I did to fix my problem:
C# extension -> Unistall -> Install another version -> Version 1.24.4
After that in the settings I searched for "omnisharp: use global mono" and set it from "auto" to "alwayse".
Then restart Omnisharp and wait for it to compile and show references.
Removing data from %temp% folder resolved my issue in VS 2022.

Visual Studio - Error when clicking on Solution -> Properties (Object reference not set to an instance of an object)

When i try to access my solution Properties, i get the following error:
Object reference not set to an instance of an object
I am using VS 2012. What could be the cause of this?
Some extensions may cause this.
Try disabling extensions and restarting Visual Studio.
Quite often error will be gone even if you re-enable extensions after this.
There's a bug report on Microsoft Connect (link).
It is marked there as "Closed as External", but it seems that it may occur randomly with any extension, so would be worth voting it there to bring it to Microsofts attention.
In my case, the problem was solution-specific. NuGet was causing this error, but not the extension itself but a NuGet package that generated an error on VS load. When I opened NuGet Package Manager Console I saw a big red text with a description of the error. In my case it was T4Scaffolding.Core package, which in turn is a dependency of MVCMailer.
If this is your case, you will probably see what package generates an error in PM Console.
I faced this dialog too and i'm not sure what exactly causes this as i couldn't even open the NuGet console to see detailed error messages.
Closing Visual Studio, deleting %AppData%\Microsoft\VisualStudio and restarting Visual Studio worked for me as it causes a reset of various things like window configurations.
I think if this dialog is displayed some files may be corrupt in %AppData%\Microsoft\VisualStudio and by deleting that folder Visual Studio can start normally again.
Update:
The issue arises on my machine when i start Visual Studio by using "run as administator" whereas Visual Studio has been started before without that option and %AppData%\Microsoft\VisualStudio had been created without the administator association.
Visual Studio 2013: I had this issue when I tried opening TOOLS -> Extensions and Updates.
I used #ViRuSTriNiTy idea, but only cleaned the files from:
C:\Users[myUserName]\AppData\Local\Microsoft\VisualStudio\12.0\Extensions
There are 2 cache files over there.
Deleted them and restarted VS2013 and it was fixed
The way it was happening for me might be unique to me/my setup, but I'd love to know if anyone else has this happen, and if they find out why:
If I launch an .sln file by double-clicking it, it will load VS and I can right-click the Solution and get Properties to come up no problem.
If I go to "Open Project" on the Visual Studio welcome page or from File > Open > Project/Solution, navigate to the .sln file and launch it by selecting it and clicking "Open" in the File dialog, that's when I have this issue.
I'm going to just always launch the .sln file from now on, but I'd love to know why this happens when using "Open Project" from the welcome page or from File > Open > Project/Solution! I tried going into Tools > NuGet Package Manager > General and I unchecked the options for allowing NuGet to download missing packages and Skip applying binding redirects, and under Package Sources I de-selected the checkboxes (my dev machine does not connect to the internet). Environment > Extensions and Updates: I tried it with and without "Load per user extensions when running as administrator" and running it as an Admin and without running as Admin. Also tried just deleting everything at C:\Users\me\AppData\Local\Microsoft\VisualStudio. No change from those 2 bullets above.

Error loading DefaultTemplate.xaml in designer

I can't load my projects' DefaultTemplate.xaml file in the designer. (using VS2010 premium, recently reinstalled)
When loading the DefaultTemplate.xaml from the build templates in TFS, I get an error saying that the activity cannot be loaded.
There are errors loading the namespaces. Somehow it cannot find the assemblies needed for TFS.
In the errors list I get about 50 complaints about these namespaces.
I've poked around in it, but never commited any changes. I've tried restoring the original version, but that didn't work.
I've tried replacing the template with the DefaultTemplate.xaml from another project, but I got the same error. I'm at a loss here. How can I fix my VS2010 or template so I can edit it again using the designer?
I can open other projects' DefaultTemplate.xaml files in the designer without any problems.
I suspect that it has to do with some setting in VS2010 or my project somehow not having the right references, but I can't figure out what's wrong or how to solve it.
Hope this or this will address your issue.
Edit:
If above doesn't work try below, you may get more descriptive error by using this. This works for windows applications on VS2008. I've never tried this with VS2010. You can debug your devenv.exe instance by another devenv.exe. Below are the steps. Give it a go...
1) Start a second instance of visual studio
2) go the the Tools menu, "Attach to process", select the 'devenv.exe' process, and click the 'attach' button.
3) In the Debug/Exceptions menu Turn on exception catching when first thrown (in the Debug->Exceptions menu).
4) Open the designer with the debugger attached
5) The second visual studion will break on your error.

Resources