Visual Studio 2010: breakpoints in dll-project - visual-studio

I'm developing a plugin for another app. After I press debug, dll is generated and put into the folder for plugins of that app, after that that app is launched. I can't use breakpoint's. they are not fired up. When I move mouse upon breakpoint, there's a hint 'this breakpoint will not currently be hit. No symbols have been loaded for this document'.
Where the problem is?
PS: And yes, i'm running in the Debug mode and not in Release. Yesterday breakpoints worked as they should. Then they start working only in main file. After I deleted .pdb file breakpoints stoped firing-up (despite .pdb file is created again after build).
PSS: I'm new to all this stuff
UPD: When I put a breakpoint into main source file. Breakpoints are fired. Compiled dll is loaded (in modules) tab.

One simple explanation is that your plugin simply never got loaded. Debug + Break All and use Debug + Windows + Modules to check if your plugin is in the list. If it is then you can right-click it and choose "Symbol load information". It shows you where the debugger looked for the .pdb file.

Is your app 'third-party'? I mean it's not a part of VS project, right?
In this case you should use Debug>Attach to process and choose main app process.

Related

devenv ignoring breakpoints

I have some issues with my Windows Forms UserControl and am unable to place it in a form. I'm trying to find the problem using design time debugging with devenv.exe but whatever I try, breakpoints are ignored. At first I had the "breakpoint will not be hit, no symbols for this document" warning but I fixed it and now there is no warning.
I know this has been answered may times, but none of these have worked for me and all out of options
Enabling DEBUG constant
Setting debug info to full
Disabling Just my code
Making sure the breakpoint is in the right place to be hit
Making sure I use the debug option before launching
Making sure I'm attached to the right process (there is only one available)
Setting the project as startup
Running VS as an administrator
Disabling Step over properties and operators
Try these:
Make sure that you used Debug configuration to debug your project.
1) reset vs settings under Tools-->Import and Export Settings--> reset vs settings
2) close Vs, delete .vs hidden folder under the solution folder, bin and obj folder.
Also, Windows Forms UserControl project is a class library project, and it cannot set up to debug directly. You should create a console or windows form exe project and then reference the Windows Forms UserControl project, after that, initialize the class with class_name xxx=new class_name();, set a breakpoint on that. At last, set the new exe project as a startup project and then test it.
3) when you are debugging, please enter Debug-->Windows-->Modules and check if your <user_control_project_name>.pdb file is loaded, if not, you could right-click on it to Load Symbols.

Symbols for Visual Studio 2005

The images below show the module window which shows all PDB files loading properly, but when hovering over my breakpoints I still see the second image, saying symbols have not been loaded. How do I get my breakpoints to work??
Modules
(1)Try to change the target CPU (X86/X64/Any CPU)in your project property, and rebuild it again.
(2)Please also make sure that it is not related to the .NET version. Make sure that your project was in debug mode, not in release mode.
(3)In your project property->Compile: https://msdn.microsoft.com/en-us/library/07bysfz2(v=vs.80).aspx, Generate debug info=Full.
(4)Enable the Symbols Server Under Tools->Options->Debugging->Symbols.
(5)Tools->option->Debugging->General-> disable 'Requires source files to exactly match the original version. Debug your app again.
Go to Debug/Options/Debugging/General and check 'Enable Just My Code'

debugging windows service gives No symbols have been loaded message

I have a Windows service and I have written Debugger.Attach() in the Onstart method of the service.
When I start the service I get a popup which asks to select the debugger instance.
When I select and press ok, the visual studio comes into focus but shows me "No symbols have been loaded" message.
I followed two steps
1.from here http://geekswithblogs.net/dbutscher/archive/2007/06/26/113472.aspx
While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project.
Look for your project's DLL, and check the Symbol Status for it.
If it says Symbols Loaded, then you're golden. If it says something like Cannot find or open the PDB file, right-click on your module, select Load Symbols, and browse to the path of your PDB.
2 goto Debug-> options and settings ->
under the debugging node -> general ...uncheck "just my code" checkbox
and it worked...
I most commonly see this issue when the build of my project that is running doesn't exactly match the build currently loaded in VS. For example, I build my VS project, then I make some (any) change to a file in the project and save without rebuilding. Then if I run the executable/service/DLL the previously built version will run and since it doesn't match the version I have in VS (thanks to my code change), it won't properly attach.
The specific issue in this case is that the VS debugging PDB file does not match the source code making debugging impossible.
This may not be your issue, but I have seen the "no symbols..." error countless times and it is usually a case of the code being executed not matching the code in VS.

Visual Studio 2010 debugger steps over methods and doesn't stop at breakpoints

My Visual Studio 2010 debugger sometimes has a very strange behaviour...
Sometimes it doesn't stop at breakpoints, but when it stops, and I want to step into a method, the debugger just steps over it. Also the breakpoints in those over-stepped methods are ignored.
When this strange behaviour occurs, it also does not break on exceptions but simply ignores them.
I've tried to rebuild my project, reset the Visual Studio settings and disabled debugger settings like "Break only in my code", but nothing has worked.
How do I solve this problem?
Here are a couple of reasons and workarounds for why Visual Studio will avoid stepping into a particular method.
Just My Code is enabled. In certain circumstances the "Just My Code" setting will prevent you from stepping into a method / property. To avoid this you can disable "Just My Code" in the debugger options page (Tools -> Options -> Debugger -> Uncheck "Just My Code")
Symbols are not loaded for the target method. If the target method is a part of another DLL it's possible that symbols are not loaded for that DLL and hence Visual Studio will not be able to step into it by default. To force the symbols to load, open up the Modules view (Debugger -> Windows -> Modules), navigate to the DLL containing the method, right click and load symbols.
The method is explicitly marked with a debugger attribute such as DebuggerNonUserCode which causes the debugger to step over the method.
The method is actually a property or operator and you have "Step Over Properties and Operators" setting enabled (this is the default). This can be disabled via the debugger options dialog.
In my case it was "Step Over Properties and Operators" in Tools -> Options -> Debugger. Just had to uncheck that and after that everything was fine, I could step into.
Another source of confusion is iterator methods that use the yield return operator because they are rewritten by the C# compiler in such a way that stepping into them (F11) is kind of a "no-op".
You must wait for the iteration to occur to break into the method's code.
I've found the solution of the problem and it is really simple:
In my solution's build configuration, the "Build" check-box of the project where the methods are, that get over-stepped, was not checked. I checked it, and now everything works.
The most important thing to check is whether when trying to put a new breakpoint inside the method it refuses to step into, if the breakpoint is filled red liked the others, or half filled or has a special "look". If it does, hover over the breakpoint you created to find out why it isn't working.
If the breakpoint looks normal but still you can't seem to step into the method, try clearing the shadow copy cache: http://weblogs.asp.net/mreynolds/archive/2003/08/11/23576.aspx
Another thing to try is to make sure that you are indeed using the DLL you've just rebuilt by adding a MessageBox.Show (or something similar) to the method you can't seem to stop at, and make sure you get the box.
I struggled with this for a while. None of the answers given worked for me. I finally got it to work by doing the following:
Make sure the project is in debug mode (all projects)
From Windows go to a Command prompt and be sure to run as administrator
Navigate to c:\windows\syswow64\ (or folder where gacUtil.exe is located)
Run the following command (substitute path below to where your debug output version of the DLL is located.
gacutil /i "C:\Users\John\Documents\Visual Studio 2008\Projects\Project1\Project1\bin\Debug\MyAppDLL.dll"
You should get "Assembly successfully added to the cache"
Now run your project and you should be able to step into the DLL code.
WAG here, but I'd say you've referenced another project in your solution by BROWSING to a dll (project/bin/debug/mydll.dll) rather than by adding a "Project Reference." If you have multiple projects in your solution, remove ALL references to each project. Then, in the Add Reference dialog, hit the "add project reference" tab and select the project you wish to reference.
Project references are always updated on a new build. But if you, say, browse to bin/release and add a reference to a dll in that directory, when you switch to debug mode and add code and try to debug it, the old release version of the dll is loaded into the appdomain and VS won't be able to hit any breakpoints (you'll notice the breakpoints are empty circles and the tooltip will say something about the code not being loaded).
I have just found another reason for the problem, and a fix. I am creating a Windows Forms application using C++ in Visual Studio 2010. I am using the FreeType library and some code which depends on it and for various reasons this code has to be compiled with 'No Common Language Runtime Support' selected (Properties -> Configuration Properties -> General). I was not able to get breakpoints to be hit in this non-CLR code.
The fix is that the main app must be compiled with 'Common Language Runtime Support (/clr)', NOT 'Pure MSIL Common Language Runtime Support) (/clr:pure)'. That immediately solved the problem. I can now debug into, and hit breakpoints in, the non-CLR code, including the FreeType C code.
I have experienced the same recently. Not sure what I did exactly though. Try to physically clean up your solution, i.e. delete all bin directories from all projects of the solution. That usually helps to solve a lot of problems.
Try disabling "Require source file to be exactly matched" option in tools->options->debugging->general.
My solution was to create a new project and load all my .vb files into the new project. Solved all of my issues.
My problem was simple. I have multiple projects in the solution and I just need to set the project I am working with as Set As Startup Project.

Why is loaded dll missing in Visual Studio's modules list?

I am currently bug hunting and need to debug into a specific dll in the release configuration in Visual Studio 2005.
At some point I closed the solution, did some other stuff and reloaded it. From that point on my breakpoint doesn't get hit and I get the infamous "No symbols have been loaded..." message. So I opened the modules window and the dll that I want to debug doesn't appear in the list anymore, therefore I cannot load symbols manually. The application behaves normal so I am absolutely sure that the dll MUST have been loaded to execute certain functions. Sure enough, if I rename the dll and start up the application it doesn't work anymore, so it also must be the right dll.
I tried setting the dll project as startup project and the command to execute to the application's exe and starting the application from outside visual studio and then attaching to the process, all to no avail.
Question is, why is the dll not appearing in the list of loaded modules although it must have been loaded? I cannot think of any other changes that I've done, that could cause this, am I missing something? (Maybe something really obvious?)
Any help appreciated!
Use process explorer to check if the dll is loaded or not.
When you attach the process make sure that you are enabling both 'Native' and 'Managed' code type (in the code type selection option).
See also this question: Visual Studio is not loading modules when attaching to process
I encountered a similar issue after transferring a project from one computer to another. I will simply explain what I discovered and how I fixed it, and you can determine if it fits your problem and solution.
The work computer I wrote an application on contained a .dll file which my program was referencing. After moving the application to my home computer, the application could no longer locate the .dll file it was previously referencing because the file was no longer there.
The application compiled and ran even without the referenced resource (.dll file) because the previously compiled assembly (debug folder) contained its own copy of the .dll file and other resources. Put simply, it is the old assembly build that is running and not the current application you're working on. This is also why this error tends to suspend the designer window and throw an error after the app is done running.
I would take a look at the following:
a) Under Solution Explorer, go into the References folder and right click the missing reference node and select properties. In the properties box, observe the Path of the resource being referenced. Is the resource still located at this path?
b) Check the debug folder for a copy of the resource you're looking for. If the resource is there, make a copy and save it to your desktop. If it's not there, get the file from the original source.
c) Under Solution Explorer, right click 'Properties' and 'open'. From the menu that appears select 'Resources' from the left and at the top of the new window that appears you you should see 'Add Resource' with a small drop down arrow. Click the arrow and select 'Add existing file' and then browse to the file. If you don't see it you may have to change the file being browsed from the small drop down above the 'open' and 'Cancel' buttons. After the file is located it should create a new folder in the solution explorer called 'resources.' Now the file is a permanent part of your application and not merely a reference to it.
I had the same issue today with Visual Studio 2008. I was using a simple tester to test a new method in an assembly. So added a reference to my assembly I wrote the code to load the assembly and call the new method, build, everything OK. But during execution the debugger would throw an exception saying that new new method did not exist, and the modules window was empty.
Turns out the assembly I was modifying was in the GAC, and was using instead of the new one in my build directory.
I had the same issue with visual studio 2017 Pro and searched for a week but no luck then i installed VS2019 Pro and test with same project but the break point wasn't working at all and the project's DLL was missing from the modules list.
I was running multiple projects under one solution and i suddenly observed that if select project1 as "Startup Project" the DLL of that project is loaded only in the module list. So as i was testing an API and I switched API project as Startup Project and observed now the API DLL files are loaded into the modules list.
Right Click on your required project that you want to include it's DLL files in the module list and set it as "Startup Project"

Resources