问题
I've specified symbol (pdb) file inside 2010 so that it is loaded correctly but I get the No source available
error and the Browse to Find Source Code
is greyed out. Does anyone know how I can specify the source code directory or look inside the pdb to find out where it is?
EDIT: My DLL is being called by an external program. The error is happening inside my DLL so I have the source code. When the error occurs I click Debug, the pdb symbols are loaded but not the source.
回答1:
If you moved the DLL from its build directory then the debugger is unlikely to be able to find the source code files itself. First thing you can do is to right-click the Solution root node in the Solution Explorer window, Properties, Common Properties, Debug Source Files and add the path to the DLL project source directory.
Second way: the debugger prompts you the first time it needs to find a source code file. If you ever clicked Cancel on that dialog, pretty common thing to do when you don't know what it is really asking, then the IDE remembers your selection and won't prompt you again. Fix that by deleting or renaming the hidden .suo file in the solution directory.
回答2:
From what I understand you just want to debug your program, that you have in form of DLL. The problem is that external program uses this DLL and you click "Debug" from the window that pops up after the error occurs.
I assume you want to open your project in Visual Studio and then press Ctrl + Alt + P to open "Attach to Process" window, where you should select process that uses this DLL (iexplore.exe or whatever you are working with) so that you can toggle some breakpoints there and see what's going on before the error occurs.
回答3:
The hack by @Hans Passant works, but there's actually an official way to achieve this: right click your solution at the solution explorer, select properties / Common Properties / Debug source files. You should be able to see and edit a list of all files where you previously selected 'cancel' when prompted for a source path.
来源:https://stackoverflow.com/questions/9036689/visual-studio-2010-c-debugging-symbols-loaded-but-cant-find-source-code