0

Trying to debug C# dll with VS 2019 and Rider 2021.1.3. Everything compiles and dll is copied to the right location as well as .pdb file. But none of the breakpoints get hit on either of IDEs.

On Rider got a notification: "Didn't find the associated module for the breakpoint..."

On Visual Studio the breakpoint simply doesn't get hit.

The code changes get propagated, so the code itself works fine and gets executed, but debugging doesn't work at all.

What I have done: pretty much everything what is described here: Debugging properties setup

Except for cleaning up AppData since there is no the directory for Temporary ASP.NET Files

Have reinstalled Rider in to the similar location on the same drive where the solution is.

Set the Debug options on VS as described in the link

Using Debug option of course.

Set the Symbols file path on Tools -> Options -> Debugging -> Symbols

Also, somewhat similar setup works for C++ project I have, but not for the C# one.

Also, when I attach to the process, then somehow the Window -> Modules doesn't show my dll in the list. Which is probably because it is a mono project. But it is 100% loaded as I've mentioned above as the code changes are picked up.

Rider setup for dll debug:

{
  "profiles": {
    "Assembly-CSharp": {
      "commandName": "Executable",
      "executablePath": "$(ProjectDir)..\\....exe",
      "remoteDebugEnabled": false
    }
  }

Update: One of the problems potentially is that I have mono.dll in the Debug > Windows > Modules, but not the dll I am working with. So, in that case, how do I explicitly see my dll in the list of the loaded modules so that I can load .pdb file manually? Is it even possible (relevant) in this case?

Update1: Found this which might be relevant in this case.

Update2: Found configuration for Unity projects (managed dlls). From this, the only relevant part is at the end with selection of the appropriate target Framework. Trying to find out of how to be able to configure it.

Irbis77
  • 163
  • 1
  • 8
  • "... and dll is copied to the right location..." What does that mean? Aren't you simply trying to run a project in a solution as Debug? I'm thinking you're either a beginner getting off on the wrong track with simple debugging, or an expert trying something most of us aren't used to for reasons not clearly explained. Please clarify. – Bent Tranberg Feb 12 '22 at 12:12
  • It is possible you are looking for`System.Diagnostics.Debugger.Launch`. Are you running this dll as part of a web service? – Bent Tranberg Feb 12 '22 at 12:21
  • It means that I am building the dll for the particular windows desktop app. The run (debug run) for that dll is triggered by executable, which doesn't get changed in this particular instance. I.e. the path to that executable is specified in Properties (for VS) to that project. I.e. on Properties -> Debug tab Executable field. – Irbis77 Feb 12 '22 at 12:29
  • If these projects are both in the same solution, then this is not the normal way to do it, and I would initially guess it is the reason things don't work. Normally the exe-project will just reference the dll-project. Is it one solution, or are you exporting your dll from one solution to another solution? – Bent Tranberg Feb 12 '22 at 12:37
  • 1
    Also, added Rider setup in to description. And I am neither a complete beginner nor an expert. I have successfully setup, debugged and made not very complex changes to the existing projects. Overall I can code and setup programming environments, but my background is mostly in software testing. Also, I am not very proficient in say C#, but I can understand the detalis (I hope) when they are explained to me – Irbis77 Feb 12 '22 at 12:38
  • Ok, good. Let's say you have one solution with a desktop app project, and a library project in Visual Studio. Below the desktop app node in Solution Explorer you'd right click on Dependencies and select "Add Project Reference..." and then add the library project. Then when you run the desktop app as Debug, breakpoints will also get hit in the library. – Bent Tranberg Feb 12 '22 at 12:42
  • 1
    In response to your question, I am modding a particular game in my spare time. It is Windows and desktop as I've mentioned. And before we get to it, it is totally respecting the rights of the people who wrote the original. But I don't have the exe project, neither I want to reverse it since the required changed can / should be done on the specific dll. This is actually an extremely common setup for the project like this. – Irbis77 Feb 12 '22 at 12:43
  • 1
    Yeah, can't do it that way (not without trying to get the exe code anyway). The setup I have now works just well with the C++ part of the project, but something is not quite right with the C# part of it. – Irbis77 Feb 12 '22 at 12:46
  • Ah, I see, but then the `Debugger.Launch` may be a good bet. It is supposed to launch the debugger when the call is made, so hopefully you can find a way to make that call as the dll is loaded. I have used it for debugging services, but not in a situation like this. – Bent Tranberg Feb 12 '22 at 12:46
  • 1
    There's more info [here](https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-from-a-dll-project?view=vs-2022#specify-a-calling-app-in-a-managed-dll-project). – Bent Tranberg Feb 12 '22 at 12:54
  • Yes, playing with Debugger.Launch. Throws some exceptions at the moment. But will try it further to see, what is going on... Thank you. – Irbis77 Feb 12 '22 at 13:34
  • At least for VS you can manually load the symbol to enable break points, https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-use-the-modules-window?view=vs-2022#load-symbols – Lex Li Feb 12 '22 at 17:02
  • @LexLi This doesn't work in this case for couple of reasons: 1) Load Symbols seems to have some issues with .pdb file, i.e. it doesn't load it it seems or not able to use it for unknown reason - so in short Load Symbols doesn't change anything 2) It seems that this is a mono project, which means that my dll is not in the list of the loaded modules and thus I can't check the .pdb loading settings that way. I am trying to check of how to see the loaded modules in that case if possible – Irbis77 Feb 12 '22 at 18:16
  • I think after all, the actual issue is that the process being debugged does not even load your dll so that symbol file cannot be loaded as well. If you cannot share more info about your setup, this isn’t something that can be further discussed. – Lex Li Feb 12 '22 at 20:05
  • Well basically it is a unity mono dll, which needs to be referenced. It can be debugged in Unity itself, which is of no help. – Irbis77 Feb 13 '22 at 14:51

1 Answers1

0

Fixed with debugging version of mono.dll as per this link here

Since the dll in question was managed dll from the Unity game built with Mono, thus apparently the debugging can be enabled with the debugging version of that dll.

Irbis77
  • 163
  • 1
  • 8