Visual Studio Enterprise 2022 "hangs" at random - c#

I have a problem when using latest version of Microsoft Visual Studio Enterprise 2022 (version 17.2.2) running on Windows 10 Enterprise (Version 10.0.19044 Build 19044, if that matters). The problem is that the Visual Studio "hangs" at random moments, but not completely. By that I mean that it looks like everything's fine with it, but I just can't click it. By fine I mean that for example when I'm debugging an application and VS hangs, the app is running completely normal, everything's showing up in VS and for example breakpoints are hit normally. When it happens, I can also close VS from the task bar normally and it unloads everything peacefully. Like I said - everything's completely normal, but it's like VS is behind a glass. Also, like I said - it's completely random and sometimes it hangs when VS is in the background, but it also happens when I'm writing and it freezes mid word. The cursor is flashing, but I can't type anything and VS doesn't respond to keyboard and mouse clicks.
It's not that big of a problem, but it is quite annoying nevertheless, especially when it happens few times a day, about once every 2 hours.
The weird thing about it is that it only happens when I'm doing stuff in a specific project - a VSTO plugin for Outlook written in C# (hence the tags). I can have multiple windows (and solutions) opened at one, but when it happens, only one of them freezes - and it's the window with the VSTO plugin for Outlook. I don't know if that's the problem with the solution/project or if it's something with Visual Studio.
Like I said - it's not that big of a deal, as I can just close it from the taskbar, but it is quite frustrating and I'd like to fix it. Any help would be appreciated.
EDIT: More than a month has passed and I think this question needs to be updated. During that month I updated everything - Visual Studio to version 17.2.5, ReSharper (more on that later) to version 2022.1.2 (from version 2022.1.0) and Windows to version 21H2. And nothing helped. However I have some observations that I think I have to share.
First of all - answering matthew-watson's question - yes, there is a plugin involved and it's the aforementioned ReSharper. I feel quite stupid, because I completely forgot that I had it installed since I started using this PC - I just didn't use it. When I started using it nothing (in terms of this question) has changed - because it has always been there. However I'm not sure if ReSharper is here to blame - at least not completely. I tried disabling it few times during that month and it seemed liked it helped, because there were no "freezes" when it was disabled. Usually after few hours I turned it back on - I like ReSharper and I'd rather not stop using it. But I'm not sure it really helped - maybe it is just so happened that there were no "freezes" when it was disabled, that it was pure accident, as there were days when ReSharper was enabled and there were no occurrences of this bug. Moreover other people in my office are using the same configuration as me (same PC, same software - including the same version of Visual Studio, ReSharper and Windows) and they don't have this bug. I'm starting to wonder if my PC is cursed...
Secondly - it's not just Office VSTO plugins that cause those "freezes" (hence I crossed that section out). Since I asked this question I changed the project that I'm actively working on and observed that the bug also happens in other projects. It doesn't matter what project, it happens in all of them - simple console projects, Blazor projects etc. However I am quite sure that it happens more often in VSTO projects. Recently I came back to the VSTO project I had been working on previously and the bug happened at least 5 times on one day. In other projects it happens rarer. Though - as mentioned in the original post - it is completely random. There are days when it doesn't happen at all and days when it happens every 30 minutes or so. It's really frustrating. But - as mentioned - it happens more often in Office VSTO plugins for some reason.
Also - I did try repairing Visual Studio by choosing "Repair" option from Visual Studio Installer - it didn't help.
At this point I kinda gave up on solving it - I tried every solution that came to my mind, checked everything and I couldn't find anything - neither a reason for this bug to happen, nor a solution. If one could at least point to where to search for the correct logs and how to debug this problem, I would be thankful.
EDIT 2: Another 2 weeks have passed and I'm sad to have to tell you that this question will have to remain unsolved. I have left the company that I worked for in which I had this problem and so I won't be able to test any solution. Especially that it was only I that got this "freezing" problem, so I won't be able to ask my ex-work colleagues to confirm that any solution posted here managed to solve the mystery and fix the problem.
If anyone gets the same problem, I hope you will be able to fix it and share some details with us. I'm really curious as to what might have been causing it.

Related

Code generation "Quick Actions" in Visual Studio 2022 no longer working in C#

Typically when I implement an interface or write code for which usings are missing it is possible to press Ctrl+. (or right click and press 'Quick Actions and Refactorings...') to get a menu of suggestions on what can be done.
Among these suggestions are options to 'implement the interface' which generates stubs for the required methods/properties or 'add usings' etc.
These are no longer available to me. Various other actions are but afaik the common theme of those not being available any longer are the ones that in one way or another generates code.
None of my colleages have the same problem. I do however have the problem on ALL computers on which my account is logged into Visual Studio. So it clearly has something to do with my settings that are synced.
I have tried resetting the settings.
I have tried reinstalling VS.
I have tried to change various settings according to various slightly related tips on different forums which addresses similar issues.
I have checked the roslyn log files for any information on something going wrong.
But so far nothing helps.
I've searched various forums and it seems like ppl have experienced the same or similar issues throughout the years but I am unable to find any thread where anyone has actually found the cause of it nor a solution.
I can't say for sure but I think this started when upgrading from 17.3 to 17.4.
Worth mentioning might be that it actually still works in Visual Basic.
There seems to be no difference if it is .NET FW, Core or 6+.
Has anyone experienced something similar and have any suggestions on what can be done to fix it?
Thanks!
Based on my testing, VS 2022 community 17.4.4 still be able to use the 'implement the interface' feature:
From your description, looks like if you don't sign in, everything will be ok.
So here are two solutions:
1, Reset the settings of the C#:
2, Turn off synchronized settings on a particular computer
Otherwise reinstall the VS will be meaningless
It turns out it was the setting:
Tools > Text Editor > C# > Advanced > Analysis > Show compiler errors and warnings for: That was set to None and should be set to Entire Solution.
I changed this a while back to make VS not use as much CPU. Had no clue it affected this.
Creds to ChatGPT for solving it where no support could!

Cannot launch applications outside of Visual Studio

I'm having a really strange problem that I just can't figure out. Things I compile in Visual Studio 2015 (C# projects in WinForms and WPF) will not launch outside of Visual Studio. This includes a project that is completely new and untouched. As in, create a new WPF Application, build in debug and release. Go to containing folders click on EXEs and...nothing.
When I run them I get 3 processes appearing in Task Manager (named the same as my application) than cannot be killed (through task manager or command prompt) and nothing else occurs. Nothing in event viewer that seems to correspond to the app. I've attached an instance of VS 2015 to the process and I get the following message: WpfApplication.exe has triggered a break point. Pressing Break takes me to a screen that tells me no debug information is available and pressing continue has no visible effects (I can occasionally see slight movement in the cpu % but not a lot else). Any attempt to stop debugging will cause visual studio to hang and when I end its process VS closes but its memory is not freed up according to Task Manager. All of these same things occur when building in VS2013 and attempting to run outside of VS. Everything runs just fine when run in debug mode inside Visual Studio but outside of it...not a chance.
I literally have no idea where to proceed from here. I can find no error messages or clues to point me in a direction to look. Is there something I'm missing/doing wrong? What steps can I take from here to find the source of the problem?
I've considered it may be something wrong with my computer but I want to explore the possibilities before I do something drastic like a clean install. If the prevailing opinion lies that way then I'll seek help elsewhere!
tl;dr: launching the exe of a compiled application results in no running application and no obvious error messages, how can I proceed from here?
I'm going to post an answer to this because I found out what was wrong but it probably isn't useful to have it hanging around so I'll just delete the question at some point soon.
The main lesson to remember is that the main purpose of anti virus software is to frustrate you as much as possible and if something weird is happening try turning it off briefly and see what happens. You'll probably find that things are now working correctly.
EDIT: I should restate this in a more serious fashion.
Anti virus can sometimes affect things in unexpected ways and turning it off temporarily can save you a lot of time. Keep it up to date too, mine was a version or so old and was not functioning correctly. I updated it and the deep scan now functions as expected rather than silently failing.

Visual Studio shortcuts in VS 2010 and VS 2012

In in development experience, strange thing I am finding having a PC in a Bank and 3 times it has got errors and changed, and now I am finding issues in VS editors, that for example, short cuts like CTRL KU for uncommenting, and commenting multiple lines together doesn't work properly and my fast typing hands using such short cuts find it difficult to perform activities.
Also, I couldn't do "Undo" of code changes which is very very scary as I used to do a lot of code changes and save and run and again I used to successfully undo everything even though its saved. But I am finding these all not happening in this PC/organization for VS.
I tried googling out for any settings to enable for these features, but futile, as I see not much settings on these found. Could someone please help me out?
Under visual studio
GO to the Tools> Options
A window will pop up. Under Environment choose keyboard.
Make sure visual C# 2005 is selected.
For Comment/Uncomment in your xml file. Make Sure following settings are present there
You might have noticed that "Use New shortcut in" is "Global". In your case it might be something else.
Do the same for Edit.commentselection

Unity MonoDevelop: Auto-complete's completely gone

I've run into the same problem as this guy on the Unity forums, which already has its own copy of the answer on StackOverflow.
Except, these answers are out-of-date.
So, running on the newer MonoDevelop 4.0.1 (compared to 2.4.2), I've tried the solution that was given;
Close MonoDevelop and delete the %AppData%\MonoDevelop-Unity\CodeCompletionData. After, reopen and MonoDevelop will regenerate all the configuration files and everything should be working fine again.
Except, the problem has gone from bad to worse:
MonoDevelop now does not list anything for auto-completion, from previously, only listing key methods/functions/whatevers (ie. void, public, If and not rigidBody, fMath etc.)
It means "an empty auto-complete box" saying: "No autocompletions found.".
UPDATE: It somewhat comes and go. One moment, auto-complete works fine, the next moment (without closing anything), it displays nothing.
UPDATE: I'm on PC, not Mac (Apple)!
UPDATE: As #Thom Denick (Not an SO user) pointed out - Tried various solutions found around the Unity answers website. None worked, since they were mainly about Mac issues (even repeating steps given in Windows did nothing). | Link 1 Link 2 Link 3.
have you tried
Opening "MonoDevelop"
Clicking "Tools"
Clicking "Options"
Selecting "General" under "Text Editor"
checking "Enable code completion"
I am on a mac. But my school has had these problems before. The way that it was fixed for us was opening the monodevelop before you open unity. Hope this helps.

Intellisense Issues in strings and methods/members

While coding in C# for Visual Studio 2010, I've noticed, that for some reason, after creating a delegate method, or using the "Extract method" menu option from Visual Studio, my IntelliSense decides it wants to go overboard. It starts activating inside a string, trying to complete stuff from outside (for instance, if I type "To be continued..." as I start to type continued, it suggests "const" as an option, thinking I'm still coding, and not recognizing I'm in a string.
Also, when it starts doing the above, it also starts doing stuff like suggesting a while loop, while trying to do a Debug.WriteLine, and the Debug class has no members listed in the IntelliSense popup window, all it lists is base classes for my current namespaces.
Now if I push ctrl space manually, I get the proper intellisense options.
Sometimes, closing all open files, and reopening them fixes it; sometimes I have to completely close visual studio and reopen it to fix it.
Is anyone else experiencing similar issues, or know of any fixes to the issue?
Funnily enough, since extensions were suggested as being the cause of the issue, an extension is actually what fixed the issue for me.
It seems ReSharper overwrites default Intellisense handling, and the folks over at ReSharper seem to do it better than DevExpress, or Visual Studio, as even just installing Resharper, and uninstalling it seemed to fix it.
I've left ReSharper permanently installed on one dev environment, and have been using it consistently now for over a year, and haven't ran into this issue once, and I used to run into it weekly, or bi-weekly.

Categories

Resources