How to Troubleshoot Visual Studio 2012 Hangs/Lockups - visual-studio-2012

I am doing PHP development in Visual Studio, and my solution contains projects for PHP, SSRS, and SQL Server (SSDT). And I am using TFS for version control. So there's a lot going on in my dev environment that can "go wrong".
I am experiencing intermittent hangs, usually around 5 minutes a clip. Visual Studio gives me the wait cursor, and if I click anywhere in VS the window dims. And then I just have to wait it out. Sometimes I can end the devenv.exe task, other times it takes several minutes to terminate the task. If I am feeling patient, I just wait and eventually (around 5 mins) VS comes back to life. I've never experienced loss of data, source control issues, etc, even when I terminate the process.
It happens sometimes when I save. Sometimes when I check-in. Sometimes when I check out. Sometimes when I build. I have been unable to discern any sort of pattern of the behavior.
All my workstation resources are fine- no RAM or i/o or network or CPU issues.
What can I do to troubleshoot this issue? Can I run VS in some sort of logging mode that would allow me to pinpoint what is taking so long during these periods of lockup?

To turn on logging in visual studio, run: devenv.exe /log
I personally would do this with a shortcut.

Consider deleting old TFS Workspace definitions left over from Continuous Integration Builds.
We had this same problem with a large Team Foundation Server project tree.
Sometimes, but not always, opening a Solution in Visual Studio 2010 or Visual Studio 2012 would hang exactly as described above. VS 2010 was most vulnerable; VS 2012 seemed less vulnerable, but it still would hang.
We were able to get some clues by monitoring the server activity on the TFS Server machine and the underlying SQL Server machine. A certain query stored procedure was using excessive CPU time in SQL Server. We tracked this stored procedure name to a TFS operation involved in scanning TFS Workspace definitions for other user's checkouts for files.
Our TFS environment has been in use for over 3 years, and we have been using Continuous Integration build definitions using a "zombie army" of developer workstations as TFS Build Agent hosts. We also create new TFS Branches for major releases. Each branch contains about 20 separate Visual Studio Solutions with their own build definitions.
Over time, we had accumulated about 2,000 TFS Workspace definitions on each developer workstation. We had about 10 workstations at one time with their own definitions.
Using the Visual Studio Command window and running as a TFS Administrator, we used this command to identify all workspaces created by our "build user":
tf workspaces /collection:tfservername\collectionname /owner:ourbuilduser >c:\tf_ws_del.bat
We then used global substitutes and the Notepad++ editor macro recorder to convert each result line into this form:
tf workspace /delete /collection:tfservername\collectionname workspacename;ourbuilduser <c:\yes.txt
where C:\yes.txt contained a single line of "y"
We also used some human judgement to remove deletion lines for workspaces named for our most recent TFS branch.
We then ran that c:\tfs_ws_del.bat script in the same Visual Studio Command window and waited patiently for it to finish.
End Result: Our Visual Studio solutions open very quickly. Even browsing the folder hierarchy in Source Control Explorer has sped up considerably.
WARNING: The deletion operations for a very large number of workspaces may expand the TempDB on the underlying SQL Server by a large amount. Coordinate with your DBA's to monitor space on the SQL Server machine. Stopping and restarting the TFS Collection via the graphical TFS Administrator Console tool helps reclaim some of that TempDB space and return it to its internal "free block" list.

This can also seem to happen when the symbol servers specified in your debug options are down or unreachable... it will not actually hang in this case but seem to as it times out for each file access.
To temporarily get around this problem uncheck the symbol servers that are down.

Related

Visual Studio 2017 crashes after 10-20 minutes

For over a month now I've been experiencing problems with VS2017 on my home PC. I even tried submitting the feedback to Microsoft. There's more info about the problems I'm experiencing there.
The problem:
The gist of it is that VS is eating RAM like crazy. As soon as I start opening files, adding new files, using IntelliSense, building or (especially) debugging, the RAM usage skyrockets.
After that it's only a matter of time before the VS crashes and restarts without any error message. Though there are numerous error messages throughout these breif ~20min I have with each session.
Additional details I observed:
Doesn't happen with Python projects, as these don't have to be built constantly. It might be eventually happening if you debug a lot, but I didn't have the chance to check that because most of my Python coding is debugged on an external device
Size of the loaded solution doesn't matter;
UWP and WPF seem to crash the most. Console Projects take longer to crash.
Also affects .NET Core;
It doesn't matter which version of .NET Framework I use;
VS2015 worked perfectly, but I don't have it anymore after the format
What I already tried:
I reinstalled VS;
I refreshed Windows;
I reinstalled Windows;
I checked my drives and RAM for issues - none found;
I switched from Community to Enterprise;
I tried disabling extensions;
I applied some shady hotfix I found somewhere;
Finally, I installed Rider which seems to be the best solution as of now. It still lacks many important features, though.
Is there anything else I can do/try/check? Did anyone experience (and fix) a similar issue?
Cheers!
You get a System.OutOfMemoryException, this means your Visual Studio runs out of free virtual address space (4GB on 64 Bit Windows for the 32Bit Visual Studio because Visual Studio is configured to be large address aware and MS refuses to release VS as 64Bit program which would fix this issue).
To analyze the memory usage, you need to run WPRUI.exe (part of Windows Performance Toolkit (which gets installed by VS2017) for some scenarios, if not, install it on your own), select Reference Set (Note: expand the Resource Analysis entry first to see all options).
and click on Start. Capture the memory usage grow for some 100s of MB and click on Save.
Open the generated ETL with the analyzer (WPA.exe) and analyze what the process devenv.exe is doing.
Also zip the ETL + NGENPDB folder (important) as zip and attach it to your bug report so that Microsoft can analyze it.

Visual Studio incredibly slow when renaming files

I have a medium-sized solution with 99 projects that has recently started behaving weirdly:
1) If I try to rename a file through the solution explorer, VS will seemingly hang, but after a long time (10+ minutes) it will complete the rename operation.
2) I also noticed today that switching to between Debug and Release mode seems to freeze VS as well. So far I haven't let it run long enough to see if that actually completes.
I've tried both Visual Studio 2012 and 2013, and both exhibit the same problem, so that seems to indicate the problem might not be with Visual Studio. I've tried to check in the event log if there's anything there, but nothing jumped out on me. I've also rebooted and run checkdisk, but it didn't find anything wrong.
Running Windows 7 Professional on a fairly high-specced laptop with 8GB RAM and a new SSD
Update: apparently if I have renamed a file once, I can keep renaming it (and other files in the solution) immediately. When I restart VS, it's slow again.
Update2: I left the computer running overnight to try to switch from Debug to Release, and it managed to do so in the 14ish hours between me leaving work and getting back here.
Visual Studio can be extremely slow in renaming files if you are using TFS with a "local" workspace as oppose to a "server" workspace, and the total number of files including different versions in the TFS repository exceeds 10,000 items.
Contrary to Microsoft's recommendation, I suggest using a server workspace instead of a local one for much better performance. There are also some other downsides to local workspaces and the only upside is being able to work while your TFS repository is down. That's not much of an upside considering if you can't connect to TFS, you probably can't connect to your LAN and there's darn little work you can do anyway in that situation.
To change to a server workspace for TFS in Visual Studio 2015,
In VS click on File --> Source Control --> Advanced --> Workspaces
In the dialog that opens, select your workspace and click Edit...
Click Advanced... (it does not matter which mapping is selected).
Under Location, select Server and then press OK.
Switching over to server may take ten minutes or more depending on the size of your repository.
Once this is done, renaming files should be nearly instantaneous.
When testing I'd made an attempt at setting up one of the projects to build on a different server, both in Debug and Release mode. I though I'd cleaned up both, but apparently I'd only done so under the Debug configuration.
Apparently meanwhile that server has decided it hates my machine, which makes my machine freeze while waiting for it.
Closing Visual Studio and manually editing the .csproj file solved the problem.
Unfortunately 99 projects is not a medium sized solution for Visual Studio but instead a very large solution. Visual Studio simply doesn't scale well to solutions of this size and you're seeing the effects of that here.
The only way to make this better is to factor out your solution into several smaller solutions.
Building on #Daniel Barbalace's answer, my issue indeed had to do with TFS, but I could not switch to server workspaces. What I ended up doing was removing the mappings to any branches or projects that I am not working on at the moment. There is no magic number but once I seemed to get under 50,000 files (globally for the TFS folder) renaming suddenly went down from 2+ minutes to 3-5 seconds.
In my case "git" cause that,i have a bunch of html files in my commics project,so,when i removed .git folder i have again fast renaming files.
I had the same issue. Renaming one file would take a decade. I found a solution however. When I first check out for edit, renaming becomes very fast again.

TFS 2012-based reports and settings open in separate browser window instead of tab in VS 2012 IDE

In the process of switching my folks over to TFS 2012, I was evaluating the team project reports I moved over. When I double-clicked on a report to open it, instead of seeing it in a tab within my VS 2012 IDE, it opens in a separate web browser window.
This behavior exhibits in migrated team projects (from 2010 to 2012), as well as newly created team projects. I'm inclined to think it's a configuration issue missed on my part, but I can't seem to nail it down.
[Migration details: upgrade performed by detaching 2010 collection, reattaching to running instance of TFS2012 on new hardware. ReportServer database was moved separately. Hardware is all WinSrv2008R2, SQL2012 Standard.]
UPDATE: altered title as this is happening to any/all settings and controls, as well, for any given team project (Security, Group Membership, Work Item Areas, etc). Anything that is URL-based. So, at least it's misbehaving consistently.
If I'm understanding you correctly, this is the expected behavior for TFS 2012. All of the controls you mentioned are part of Web Access and should be viewed/altered in a browser and not VS.

Dotfuscator Causes TFS Build to Hang

I am having trouble getting builds to complete when they are set to run Dotfuscator on files. My environment is Visual Studio Professional 2012 paired with Team Foundation Server 2012, thus I am using Build Definitions and the Microsoft Team Foundation build architecture (build controller, build agents, etc).
My problem is that when I launch a build definition in Release config, which is set to run Dotfuscator Professional on my output files, the build hangs (either that or runs for so long that I have yet to see one complete). The log file shows that it is hanging during the build process template activity "Associate Changesets and Work Items", and task manager on my build server confirms that at this point Dotfuscator is running with huge CPU and memory requirements (around 50% CPU and I've seen near a gig of memory required). Here is the latter portion of the build log...
Find Property Values
CurrentLabel =
LastLabel =
Result = (Collection)
UpdateWorkItems = True
Final Property Values
Condition = True
Final Property Values
Condition = True
The last lines are duplicated on purpose, this is exactly what the log reads. This is where the build hangs and Dotfuscator is still running on the build server.
And here's the interesting part, when I do a local build on the build server (right click on solution, click rebuild) the build runs great, done in under a minute Dotfuscator and all. This suggests to me that something is going on between Dotfuscator and Team Foundation Build. Possibly something to do with the Build Process Template and/or Build Agents? I'm not much of an expert on Team Foundation Build other than the work I have done getting to this point.
Any ideas on what I can do to get Dotfuscator to run faster or correctly (depending on the cause of my error)? All help is much appreciated.

Visual Studio 2012 RTM intellisense: fix for "hang/pause"?

I've just installed the Visual Studio 2012 RTM on a Windows 7 x64 desktop.
Unfortunately, I'm very underwelmed by the performance of the out-of-the-box installation. Everytime I try to rename a file in the solution explorer, change to a MVC cshtml editor, open a designer view, or intellisense pops up when I start typing with the c# editor, the whole visual studio applications hangs for 5-10 seconds.
There are no customizations, plugins, extensions enabled here that do not get applied with the standard installation.
Has anyone else experienced this? Has anyone else found a way to log the application faults which occur, or detect the hang. I need some way to determine what is going wrong, in order to identify what needs to be altered to rectify the installation.
The problem is you are consuming the lot more resources of the system which is causing hung state of VS. Please close any of other application who is using more RAM. You can take the help of Task Manager to close those application. Please keep in mind if you are running SQL standalone database instance services then its also causes the hand issue. The best is keep you system free from running unuseful application or Go for System upgrade. :-)

Resources