On my current project I find that I’m working with Visual Studio on a VM that is in an isolated domain, which is making life interesting! One of those ‘interesting’ things was that Debugging in Visual Studio was horrendously slow! It would take several minutes to get to the first break point (first line of a unit test), then still be slow when accessing other parts of the code.
The slow part of the process was the loading of the symbol files for each of the referenced dlls, including those of the .NET framework. As it turns out Visual Studio actually loads the symbol files for the .NET Framework from the internet! So the delay is primarily due to timeouts which lead to an unbearable (read unusable) debugging environment. The good news is that there is a solution which is quite simple and easy to implement.
In order to dramatically improve your debugging you need to have Visual Studio use a cached version of the symbol files, as well as ensure its not trying to locate symbol files on slow network shares.
Here are the steps you need to fix the issue:
- Create a directory to store you locally cached symbols. Ie C:\Temp\SymbolCache
- Change the debug settings for loading symbols, via Tools|Options|Debugging|Symbols.
- (Option 1) Start debugging the code you want (on a machine that can access the internet; even if its slow) and have it sit on a break point. Then go back to the Symbols settings, where you’ll notice the button Load symbols from Microsoft symbol servers is now active (because that was obvious!). Click the button and you’ll see a popup windows indicating the download of the symbol files. After this is complete you can close out of this window and stop debugging. If you now check your Symbol Cache directory you’ll see you have a load of downloaded symbols (may vary depending on what you’ve referenced).
- (Option 2) If you have already done option 1 and you need to apply this to another machine, such as a team members machine, you can simply copy the files from one machine to the other.
- Depending on your environment you may also have one of two environment variables that need updating. Set either of these environment variables to the same location as the cache created in setup 2. The environment variables to change are _NT_SYMBOL_PATH or _NT_ALT_SYMBOL_PATH. The default setting for these are pointing to the Microsoft Symbols server. You can access the variables either via DOS (set command) or via the Advanced System Properties dialog in Windows.
One you’ve completed the changes you should see a dramatic improvement in your performance. Remember to check in Step 2 that you don’t have any non-existent paths or UNC paths defined as this will also slow things down.