Debug randomly acting slow in Visual Studio - visual-studio

Yesterday i had worked on this solution and ran it with debugging enabled perfectly well on two systems yesterday, and today i tried debugging it and it took about 15 minutes for the window to even appear. I didn't change any settings, change any code, etc. Ran it with the exact same build as the day before, on a different system yes, but both systems ran the code perfectly fine yesterday. Now they take an extremely long time to even start and once finally started it is unusably slow in debugging mode. Note, this doesn't happen when i disable debugging. I've tried multiple things, such as cleaning, rebuilding, deleting .suo files, and more. I am wondering how to fix this problem which i think primarily has to do with visual studio's debugger, my project, or my solution, as this doesn't happen with any other projects.
I am using Visual Studio 2017, and this slow debugging is only the case for this project.

I figured it out accidentally when changing the 'enable native debugging' setting on. Having it on was making the debugger load a lot of .pdb files that i didn't need.

Related

Why VS2019 get suddenly very slow and laggy while trying to debug a c# application?

I am working on a c# code for the last couple of weeks and I debug it very often.
VS 2019 was working properly but suddenly it got very slow and laggy when I tried to debug my code.
I checked all resources on my machine. All seem as before and are available enough.
Even I checked the same IDE with other codes. All runs and debugs fast enough as before.
I also updated my IDE to the last version (currently 16.8.5 by the end of February 2021).
Did anybody has the same experience with the VS2019 ever?
Thanks in advance.
Not sure whether the issue is caused your code with IDE environment together. Please try the following suggestions:
1) disable any third party installed extensions under Extensions-->Manage Extensions-->Installed to check whether an extension caused that.
2) reset settings under Tools-->Import and Export Settings-->Reset all settings and you can also make a backup of the settings
3) close VS, delete all files under C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\16.0_xxx\ComponentModelCache
and also delete .vs hidden folder under your solution folder, bin and obj folder.
4) type devenv /safemode under Developer Command Prompt for VS to start a pure VS and then try your project.
5) create a new project with your same code and check if this works.
Besides, if all do not help, you could try a small reproducible sample with us.
If debugging suddenly becomes slow, you might consider checking your symbol settings and debugging settings. If you for example enable .NET framework source stepping, debugging can be slow, or if you do not cache symbols or disable for example Just My Code or enable other stuff, like IntelliTrace or install a bad extension.
It might not be an alternative for you, but I am pleased to inform you that I have been using Visual Studio 2022 and it is radically faster. Yes, this is not opinionated, this is an observation. It IS faster. Maybe it is because I do not have many extensions on it, but it is also a 64-bit application with less memory pressure on the GC. So you can first check your settings and then give VS 2022 Preview versions for a spin. I have used it for months and the amount of bugs are rather small if you do typically development. For a Preview version, I am impressed with what they are working for nextgen Visual Studio.
You should also clean your solution and delete and bin and obj folders via for example Powershell script to make sure your binaries are updated. Then rebuild.
If you have "live share" extension enabled, perhaps can try to disable / uninstall that. This one was causing my problem.
Ok, #Mr Qian no 3 did the trick for me.
Situation: After a "Cleanup" (Microsoft Visual Studio\Installer\InstallCleanup.exe) my VS2019 was partially gone. Good tool. :-(
After (re)install, I had 2 folders "ComponentModelCache" over 2 folders of 16.0_xxx : 16.0_4f678462 and 16.0_119826cb
I renamed both "ComponentModelCache" folders (you can delete later, when it has effect)
Build ran as never before...
Thank you, Mr Qian
My problems started as I upgraded to Visual Studio 2022 (from 2019) and upgraded to Windows 11 (naughty naughty, two major changes).
Turns out Windows Defender didn't preserve my exceptions. Using this PowerShell script as a template saved a bit of time:
https://gist.github.com/Braytiner/be2497d1a06f5a9d943dc7760693d460
Performance is back to where is was pre my Windows 11/Visual Studio 2022 upgrade.
Visual studio 2019 (16.8.5) has this problem in debugging. I have updated it into 16.11.8 and it works properly.

Visual Studio 2015 debugging slow to load

Just suddenly over the past day I'm having an issue with Visual Studio 2015 where it takes an age to start debugging anything. Even a simple console application with one line will take over 3 minutes just to start. Running without debugging is normal.
Things I've tried:
Enable Just My Code checked under General Debugging options
Created local cache of Symbols
Removed all Breakpoints
Deleted all user temp files
Reinstalled Visual Sudio
Nothing has had any effect. When starting debugging it just hangs and VS becomes unresponsive for a couple of minutes until it then will start debugging. Once running it is fine. I don't understand why this has suddenly just started happening.
My company have recently pushed McAfee out to all machines, but this has been running on mine for a while now without any issue so not sure why it would suddenly be causing this now. Has anyone else experienced this and if so how did you fix it?
I have disabled Just my code and disabled also diagnostic tools during debug in Tools->settings->debug

Visual Studio - how to reverse optimized code

I need some help. I have put in dozens of hours into a VB.NET project, it has been built in release mode and distributed. Now I have to make some changes to it, and I am unable to debug it properly. My code changes result in behavior where my code is not even recognized.
Also, I installed Visual Studio 2013 recently (moving from 2010), but this project behaves the same in both environments.
I believe that my code has become 'optimized'. The error window tells me that code is being skipped over, and that my code is optimized and JIT is checked.
I have turned off JIT, and I have tried everything to make this project work again that I could think of. I am desperately wanting to know how I can get this project to be in a state where it will debug each line of code again when I make changes.
I can even purposely write bad code, and the debugger does not see it.
This project is now in debug mode, not release. I have checked and followed threads on every thing that other people have done to solve this issue, but nothing works for me.
Either my project launches and works properly as it is coded, or if I change any code only the form launches with no code being run - at all.
please help.
I finally figured it out. The applications that I was struggling with were all built in Visual Studio 2010 on Windows 10. I was trying to work with these in Visual Studio 2013 on Windows 7.
Once I tried to work with them on Windows 10 (visual Studio 2013 this time), they started working and debugging just fine.
I think it may have been DLL assembly paths? Took me more than a week, but I figured out my issue by moving from Win7x64 to Win10x64.

Visual Studio project execution stopped shortly after starting

Yesterday I wanted to continue working on a project of mine, so I started Visual Studio and asked it to run the project to remind myself, what was already implemented and what wasn't.
The project got built and started, but seemed to quit right away. No error message, nothing.
No matter what I did, whether I rebuilt the project or cleaned it, nothing changed.
This didn't make sense, since the last time I tested the project, it worked perfectly (and I didn't modify anything in the code since then)
So, I assumed I had a hidden bug somewhere in the code, that just didn't show up previously.
I put a Breakpoint somewhere near the beginning of the code, and ran the project.
As expected, Visual Studio paused the execution at the Breakpoint and highlighted it.
I decided to set another Breakpoint somewhere later in the code and continue execution, but before I could even move my mouse, the project stopped.
Restarting Visual Studio didn't help, but restarting the PC did. Therefore, I'm assuming that something on my system was terminating my project, shortly after execution begun.
Now my question is: What exactly happened, and especially: why did it happen?
The problem came back while I was writing this question. I don't feel like restarting my PC every couple of hours...
I really appreciate the time you took reading this and I look forward to your answers.
I'm aware that I'm answering my own question, but since I've solved it myself, I thought others might want to know how I did it (for the sake of future generations)
The thing is: I've recently added Visual C++ to Visual C# before Visual C# started having problems.
So I deduced, that maybe the installer for Visual Studio messed up with something and decided to reinstall Visual Studio.
Problem solved.
So: if your projects stop without warning even while paused on a Breakpoint and you've changed something in your Visual Studio installation (like added Visual C++ in my case), you might need to reinstall the whole thing.
Luckily, the Visual Studio installer offers a "Reinstall" option, so you don't need to uninstall and reinstall manually.
I found about this solution, after talking to a more experienced colleague. I just wish I asked him first. Still appreciate your efforts in the matter, though.
EDIT:
I recently noticed a similar bug acting up for C++ programs this time, where the window border would be outlined in red. The thing is: it's not Visual Studio's fault, but in fact Avast Antivirus' fault. More specifically, its Sandbox mode.
So, if for any reason, you notice programs quitting without crashing, shortly after starting and their window border having a red outline, you're very likely using Avast Antivirus and should deactivate the Sandbox mode.
Happens to me from time to time.
Sometimes closing and opening VS helps, sometimes you have to restart the computer.
I assume it must be related to some DLL or something that is loaded into memory and corrupt, or something like VS loosing the reference to it, and not unloading it correctly/replacing it.
I also once had this strange bug, where I started VS, just like any other day, and my project crashes instantly with some H_RESULT error (some DLL related Error) upon run. After having spent around 1hour searching for the source of the problem, I went into the reference section, and what did I see there : the worst possible circular reference ever : my business project had a reference to ... itself ! The kind of stuff you could not do if you wanted to.
The weirdest part of this, must of been that VS managed to compile the project, and it only crashed while trying to run it ...

Visual Studio 2010 Periodically Hangs for Several Seconds

I'm having a problem where VS2010 Ultimate is freezing up every so often for several seconds before returning to normal operation. This happens several times during a session, and is obviously very annoying. I haven't been able to pin it down to any specific activity-- it seems to hang whenever I scroll around in a document, open/create a document, basically anything. Anyone else have this issue or know what might be the cause?
Incompatible add-ons or system configurations can cause Visual Studio issues (performance issue, error, etc).
Fortunately we can try to troubleshoot the issues by referring to the Visual Studio activity log.
Simply run the following command to run Visual Studio 2010 and log its all activities.
DevEnv.exe /log
The log file will be generated to:
XP
%USERPROFILE%\Application Data\Microsoft\Visual Studio\10.0\ActivityLog.xml
Vista & Windows 7
%USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\10.0\ActivityLog.xml
Once you run it, 2 files will be generated: ActivityLog.xml and ActivityLog.xsl
And when you open the ActivityLog.xml, it will contain something like this:
The problem was solved by deleting the user options file called SolutionName.suo.
Somehow it had gotten very big and probably corrupted. You will only lose your breakpoints and open files as far as I know, but rename it to be safe.
I know people have had problems with computers that are older or don't have as much RAM. I know my use of VS 2010 ultimate can run to 500 MB's sometimes and if you don't have enough RAM, then it will hang for a little.
I've had issues with VS2010 when debugging is running or if I'm opening files from a network drive. I'm not sure as I currently don't have any team server repos connected, but if you do maybe the connection to the repo might be an issue as well.
Turns out the issue was network related. One item in my solution was looking to a mapped network drive, which apparently didn't always respond fast enough.
My solution for that problem was beyond the scope of my thinking. I found it on this website, and it goes like:
Launch Internet Explorer. Go to Internet Options, then Advanced tab. Under the Security group, untick “Check for server certificate revocation“. You may need to restart Visual Studio.
My scenario is that I have network drives with references mapped via VPN. That should have to do with that.
I faced similar issue with Visual Studio 2008. I have not thoroughly investigated the issue though.
Reading your post it seems the behavior at your PC is really annoying, but for me it's not that frequent.
One thing I noticed, the frequency at which this happens is dependent on the RAM size and time elapsed since last setup. I came to this conclusion seeing the performance of machines of my colleagues.
I noticed that my anti-virus software tends to lock down my entire system sometimes. If you have an anti-virus application, you might try disabling it for a moment to see if it is the culprit.
I had a similar issue - that still happened after a /resetsettings, reinstall and using /safemode. For me, the issue was that Assembly Binding logging was turned on ago and I forgot to turn it off, it got to the stage where the log files concerned were >200MB and each append was taking ages...
Managed to find the issue with procmon from sysinternals. Suggest that anyone who comes across a similar issue tries procmon if none of the above solutions help.
My VS2010 would hang as well in a similar fashion.
DevEnv.exe /log would indicate it failed to load strings around the time it would hang.
Reinstalling VS2010 SP1 and deinstalling Resharper to install Resharper 7.1.3 solved the problem.

Resources