2

is it possible to debug through code in System.Windows.Forms?

Debugging of other .NET-framework code with "Enable .NET framework stepping"-setting and matching symbols (for instance received from Microsoft symbol servers) works like a charm for me, but for stackframes within System.Windows.Forms, no code is provided (see screenshot), although WinForms code is available in the .NET sources and not closed-source.

stackframes within .NET framework and WinForms

  • Disable 'Just My Code'? Go to *Options and Settings* on the Debug menu. In the *Debugging / General* node, choose or clear Enable Just My Code – mcalex Jun 12 '18 at 07:43
  • 'Just my code' was disabled the whole time. As I said, debugging through the rest of the .NET framework works. – Matthias S. Jun 12 '18 at 07:49
  • 2
    https://stackoverflow.com/a/27655501/17034 – Hans Passant Jun 12 '18 at 13:20
  • 1
    Any luck? I am having exactly the same issue. I have all the settings set, source code downloaded (for the target version and what I have installed), I can step in to other code, but when I try to Step In to Forms code it simply steps over without any prompt whatsoever. It is really frustrating because I started all this just to step through some Form code, nothing else, and so far nothing works. – RTHarston Jan 31 '19 at 21:14
  • unfortunately not. – Matthias S. Mar 15 '19 at 10:16

2 Answers2

1

You have to download the exact .NET Framework source code for the targeted version of your application (from http://referencesource.microsoft.com/). See .NET Framework source code debugging for more details

enter image description hereenter image description hereenter image description here

and then browse to the downloaded source code (for example: "D:\Downloads\Source\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs")

Danut Radoaica
  • 1,860
  • 13
  • 17
  • 2
    Checked this multiple times. This is not the point. I can debug through every single piece of code in the framework, except for WinForms stuff. It's not even possible to specify source files for stackframes within System.Windows.Forms. – Matthias S. Jun 28 '18 at 20:48
  • Enable .NET Framework source stepping as mentioned above. Download the source code from the link mentioned above. When you hit "F11" to step in code from System.Windows.Forms.dll the "Source Not Found" window will appear, click the "Browse and find .cs..." (for example: "Browse and find Application.cs...") and then browse to the downloaded source code (for example: "D:\Downloads\Source\ndp\fx\src\winforms\Managed\System\WinForms\Application.cs") – Danut Radoaica Jun 28 '18 at 21:31
  • 1
    No. Just no. Of course, source framework stepping is enabled. I mentioned this in the start post. I can debug the rest of the framework, so the settings are corect. It never asks for source for WinForms. Found a post on Microsoft Social or so, where someone else has a similar problem. He mentioned that after a certain Win10 update, he couldnt debug through WinForms any longer. Also, his WinForms pdbs were smaller than before, which may be the causr for the problem (source info missing in pdbs) – Matthias S. Jun 30 '18 at 19:27
  • I have windows 10, latest updates, and the above approach works for me in a windows forms application. Hope you find a way – Danut Radoaica Jul 05 '18 at 21:45
  • Radoaica, could you try to debug through a method which is in the System.Windows.Forms namespace? Application.cs is in System.Windows, debugging through classes in this namespace works for me, too. Maybe you could try to debug into Form.Show() or something like this? – Matthias S. Jul 07 '18 at 10:48
  • Matthias S. see the last image from the edited answer. The problem with this approach is that some of the classes are modified by windows update and you will not find the exact source code for your .NET Framework version (on https://referencesource.microsoft.com/ are only: 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2) – Danut Radoaica Jul 07 '18 at 14:14
0

I have exactly the same problem (with .Net 4.6.1, and 4.7.2) I can debug e.g. the System.dll module but I cannot debug System.Windows.Forms. All settings are correct, pdb files are downloaded to disk, in the modules window I see that symbols are loaded. But debugging doesn't work. I believe the System.Windows.Forms.pdb file does not contain all the necessary information. I checked the System.Windows.Forms.pdb and System.pdb files through the cvdump.exe utility. The System.Windows.Forms.pdb file does not contain information about the names of the source files. I think that is why during debugging the window asking for the location of the source file does not appear.

Green
  • 688
  • 5
  • 8