When there are a deep chain of function calls, especially when the managed and unmanaged code are intermingled together, it’s getting more trickier to debug. One situation is that an exception is thrown deep at the bottom of the chain and caught at some level after it’s relaid/re-thrown by a couple of levels and the message logged by the exception handler code is too generic to help locating the root cause of the exception. In this case Visual Studio could help locate where the exception is actually thrown at the beginning. This helps a lot in narrowing down the problem when debugging in a large code base.
After loading the project into Visual Studio, bring up the exception dialog by menu "Debug" => "Exceptions…" and check the types of the exceptions that you want to investigate. After this attach to the process in question. Whenever the statement will cause exceptions to be thrown, it will prompt and let you choose whether to break at that trouble statement and do further investigation.
Programming
debug, visual studio
When you can’t set break points when the debugger is running, it’s most likely due to symbols loading related problems. Instead of smashing your computer, check the following first:
- Make sure you really setup the symbols. Tools -> Options -> Debugging ->Symbols. Add all the paths where expected .pdb files are stored. Also make sure the permission is set correctly on the folder, especially for remote shared folders. Use "net use …" command if necessary.
- In VS2005, Tools -> Options -> Debugging -> General. Uncheck "Just my code".
- Make sure the application is running in debug instead of release mode. Check web.config file for tag <compilation debug="true">, or right click the solution in the solution explorer and choose properties.
- The timestamp of the .pdb files and their corresponding .dll files are in sync. The unmatching symbol files are not picked up, because if they are not matching, there could be unexpected harmful running results.
- Check the Module window (Debug -> Windows -> Modules) and make sure all symbols are loaded when running the debugger.
- Delete bin and obj folders, restart VS or OS and retry.
- Delete the project and fetch source tree again and retry.
- If none of the above helps, go ahead and smash your computer.
.NET
debug, symbol, visual studio