Symbols wont load for my project - c#

I have a project I was handed that I unzipped, put on my computer, and now I can't put any breakpoints in. Whenever I try to put a breakpoint in I get an exclamation point over the breakpoint saying "This breakpoint will not currently be hit. No symbols have been loaded for this document." Anyone know how I can fix this? This error doesn't show up until the I start to run the code, while the code isn't running the breakpoint looks like it is there just fine.

I'd guess that you might be running a release build? Check the project settings to make sure it's a debug build, otherwise breakpoints can be ignored due to compiler settings sometimes since the optimizations can make the debugger a bit upset.
Might also be worth doing a clean and rebuild all to make sure that you're running against the correct version of the binaries etc.

Here are some things you can try:
Open up the properties page of the project(s) and select the "Build" tab. Click on "Advanced". Make sure where it says "Debug Info" that "Full" is chosen.
Additionally, delete any PDB files in the output folder.

Related

Is it possible to attach dll's to the debugger that are not referenced by any project in solution?

Just as the title asks. I have solution with 5 projects in it. All dlls are connected with each other and whenever I start debugging, I can freely debug any of them. I'd like to add a separated project and access it's object by using reflection only (no references between the rest and 6th proj at all). Can I make it attach automatically to the debugger? I'm aware of function 'attach to existing process' but that's manual job.
You don't need anything special. Make sure you have pdb file next to the dll for that separate project, have source code locally matching to the version used to build that project, and possibly turn off "my code only" in tools -> options -> debug. At that point Visual Studio should pick up debugging information and allow you to set breakpoints and debug normally.
If PDB located somewhere else you can manually point to the PDP via debug->window->modules view by selecting "load symbols" from context menu on module you are interested to debug.
If sources don't match exactly you can instruct VS to use whatever you have also it likely will lead to confusing debugging experience (How does Visual Studio know if the source file matches the original version?).
You can put below line in your debugging dll ,in which function you want to debuge. it automatically ask you to attach with debugger
System.Diagnostics.Debugger.Launch();

Visual studio Show disassembly window and shows a message that says "Source might have changed"

I have been trying to figure out what is the cause of this weird problem since morning. I have all my projects in a single solution. and they refer to each other with project reference not a DLL reference. So I expect them to update and notify each other whenever any code change happens.
Now, while dubugging the code,when I try to step-into a method which belongs to a particular project, it shows me diassembly window. I have no idea why am I seeing such a window. I did browse online and some people suggested that I should disable "Enable just my code option" from Debug menu. I did try that as well but no help so far.
I was also seeing another dialog box saying that "Source code might have changed in other assembly" but that is replaced by this disassembly widnow now.
I have no idea why each of them are showing up and also no idea why it switched from the dialog to disassembly window.
Also, If it clean + rebuild the solution, it allows me to step into that project ONCE but after that the same story starts happening. Any ideas?
This error happens when your .pdb files don't match your .dll files.
Maybe you have some post-build events changing things, or you have several builds outputting to the same location?
If you are copying another project's assemblies into your project, make sure you keep the .pdb files in sync.

use VS.NET to debug application

I am using VS.NET to attach to a process, the process has a lot of DLL loaded, I built one of the DLL and try to set a breakpoint inside my DLL. I click "New Breakpoint" and type my function name Func_A and checked the "Use Intellisense to verify" box. Then I click OK but the VS.net complains that it can't find the function.
When the process is attached I checked the output of VS.NET, it didn't has a "can't load symbol" message behind my DLL line, so I think it has successfully located my PDB file. I don't know why I can't set the break point.
My project is C# managed project. Note that for all the DLLs, some has debug informations, some don't, but I believe VS.Net has identified my debug informations.
Please suggest other ways to try...
Another question is is there any tool to see the functions that can set breakpoint in an assembly DLL file?
If you see a lot of DLLs loaded then it is likely that you are running the debugger in native mode. It is an option in the Tools + Attach to Process dialog, be sure to pick Managed.
By far the easiest way to avoid trouble like this is to load the source code file and set the breakpoint by clicking in the left rail of the editor window. Also, don't use Attach to Process. Use Project + Properties, Debug tab, select "Start external program" and select the .exe that loads your assembly. You can now start debugging by simply pressing F5. Beware that this option is not available in the Express edition.
Could do with some more details really, but here goes...
Do you have the source for the DLL? If so, just open the code and add the breakpoint wherever you want.
If you don't, then you're pretty much relying on Intellisense which isn't always reliable I've found, particularly if managed C++ assemblies are involved. To help, you could look at the DLLs using Reflector to get the full namespaced function name and try that, ignoring Intellisense.
Using reflector will also let you see if the DLL is obfuscated (if 3rd party).
Hope this helps give you some new ideas of how to tackle it.
K

breakpoint insertion in C#

I am unable to put a breakpoint.
I am getting the message in the breakpoint like:
"break point will not be currently hit, no symbols are loaded"
there are a few solutions. The problem is that the symbols loaded dont match the executable.
1) Make sure the exe you are attached to have its PDB's in the same directory and its the same version
2) make sure your source code is the same version as well
3) when debugging , open the modules window (debug --> windows-->modules). Choose load symbols and choose your pdb
If your unsure on what to do, then rebuild everything and run
oooops . i didnt read your post properly, i assumed your using visual studio. Anyway, if your not , just find where in your IDE you need to set the symbols and check there.
Another issue is that the breakpoint is that it may be set to a blank line.
Sometimes if I have another instance of Visual Studio open as well as the one I'm trying to debug with, it plays up, especially if I've been debugging in that other one.

Debugging into C# code from other application

I'm loading a dll (c#) from QTP. Is it possible to debug the c# code when the qtp test starts.
Yes you can debug into the dll's you can, but you will need source (unless you want to look at the disassembly) and you will also need the PDBs (debug symbols) for the assembly. It is pretty easy to setup...
start the QTP application
start visual studio
open the source code and make sure the pdb's are in the same directory as the dll
in VS go to the debug menu and select attach to process
In the process list, select the QTP process and click "attach"
Set a breakpoint in the code
Start the tests that execute the code and if all is well you should hit the breakpoint
NOTE: if the breakpoint is not hit, VS probably can't find the PDB's and you either need to add a path in options in VS (or something so it can find them).
Also, try turning off "Enable just my code" in the Tools->Options->Debugging options page if it is still not working (mostly if you are looking at release built code).
Update: Answering comment... If you go to Tools->Options... Select "Debugging" on the list on the left and expand that, then select "Symbols" you can add paths there for VS to search for symbols. Also, if you don't have the exact symbols you can right-click the breakpoint and select location and check the option that will allow the symbols to be out of sync.
Hope this helps!
You can insert a call to Debugger.Break()and run the external application, when the break point will be reached Windows will offer you to debug the exception.
Choosing debug will enable you to run the code after the break inside Visual Studio and set break points inside your code.
In case you're using Vista/Win7 you might need to enable debugging - have a look at this post to learn how.

Categories