netdbg — Getting started

Debug 32-bit (x86) .NET applications, such as WinForms apps built for x86, in Visual Studio Code — with many of the debugging tools you know from Visual Studio, and a few it doesn't have.

What it is

The C# extension for VS Code ships its debugger only for 64-bit and ARM64, so a process built with <PlatformTarget>x86</PlatformTarget> cannot be debugged with it. This extension bundles its own debug engine, netdbg (x86 and x64; the one of the program's bitness is used), and adds the debug type netdbg. The debugger itself uses no .NET. The differences from Visual Studio and from netcoredbg (the engine of 1.x) are listed in the README.

You need

Windows (64-bit), VS Code, a .NET SDK, and the x86 .NET runtime your app uses — for WinForms / WPF that is the .NET Desktop Runtime (x86).

Supported

.NET (Core), .NET 5 or later and .NET Framework 4.x, 32-bit and 64-bit processes (self-contained and single-file too): launch and attach. .NET Framework apps need no other .NET; the project must write Portable (or embedded) PDBs.

Not supported

.NET Framework 2.0 / 3.5, and Windows PDBs. The debuggee's output goes to the Debug Console (no integrated terminal).

Install

  1. Open the Releases page and download netdbg-<version>.vsix and install-vsix.ps1 into the same folder.
  2. In that folder, run:
    powershell -ExecutionPolicy Bypass -File install-vsix.ps1
    Alternatively, in VS Code run Extensions: Install from VSIX... from the Command Palette (Ctrl+Shift+P) and pick the file.
  3. Reload VS Code (Developer: Reload Window).

Menus and messages follow VS Code's display language: English, or Japanese with the Japanese Language Pack.

Your first debug session

Quickest: open the project folder and run .NET x86: Getting Started from the Command Palette. .NET x86: Check Environment shows whether the x86 .NET runtimes, the .NET SDK and your projects are ready (with a button that fixes the project file), and .NET x86: Generate launch.json writes steps 1–2 below for you from your .csproj files — pressing F5 without a launch.json does the same. The steps below are what they do.

1. Make the project 32-bit

<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>net10.0-windows</TargetFramework>
  <UseWindowsForms>true</UseWindowsForms>
  <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

2. Add a build task and a launch configuration

.vscode/tasks.json:

{
  "version": "2.0.0",
  "tasks": [{
    "label": "build", "type": "process", "command": "dotnet",
    "args": ["build", "${workspaceFolder}", "-p:Platform=x86"],
    "group": "build", "problemMatcher": "$msCompile"
  }]
}

.vscode/launch.json (type .NET x86 in the Add Configuration... list to insert it):

{
  "version": "0.2.0",
  "configurations": [{
    "name": ".NET x86 Launch",
    "type": "netdbg",
    "request": "launch",
    "preLaunchTask": "build",
    "program": "${workspaceFolder}/bin/x86/Debug/net10.0-windows/MyApp.exe",
    "cwd": "${workspaceFolder}"
  }]
}

3. Set a breakpoint and press F5

Click left of a line number to set a breakpoint (a red dot), then press F5. When the app reaches the line, it stops and VS Code shows the values. Use F10 (step over), F11 (step into), Shift+F11 (step out) and F5 (continue).

A program built without PlatformTarget (AnyCPU) runs as a 64-bit process and is debugged with the x64 engine. To debug it as x86, set <PlatformTarget>x86</PlatformTarget> and point program at bin/x86/....

A tour of the screen

While stopped, the Run and Debug side bar (Ctrl+Shift+D) and the editor look like this.

RUN AND DEBUG ▾ VARIABLES ▾ Locals this: {MainForm} sender: {Button} e: {MouseEventArgs} ▾ WATCH ▾ CALL STACK MainForm.OnButtonClick() Program.cs 36 ▾ BREAKPOINTS ☐ All Exceptions (when thrown) ☐ User-Unhandled Exceptions Program.cs 36 ▾ AUTOS (.NET X86) _count = 3 ▾ EXCEPTION LOG (.NET X86) 2 ⚠ FormatException: The input string… ▾ STEP HISTORY (.NET X86) #3 MainForm.OnButtonClick() · 1 changed ▸ MODULES (.NET X86) Program.cs 33343536 37383940 private void OnButtonClick(object? sender, EventArgs e) { _count++; _count = 3 UpdateLabel(); ≤ 12 ms elapsed total += _count; } DEBUG CONSOLE total=3 total=6 Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll ⏱ load: ≤ 84 ms
Stopped at a breakpoint in a WinForms button handler.
  1. Variables — locals of the selected frame. Right-click a variable for the extension's commands.
  2. Autos — only the variables used on the current and previous line.
  3. Exception Log — every exception thrown, even those caught and swallowed (with a count badge).
  4. Step History — the locals at each earlier stop; changed values are marked.
  5. Inline values — the current values printed at the end of the lines.
  6. PerfTips — how long the last step or continue took.
  7. Breakpoint (red dot) and logpoint (diamond) in the gutter; the yellow arrow is the current line.
  8. Debug Console — logpoint messages, exceptions and section timings.

Features

Feature list

Grouped by what you want to do. ★ marks features Visual Studio does not have.

FeatureWhat it doesWhere
Stopping where you want
Conditions, hit counts, logpointsStop on a condition or the n-th pass; print without stoppingGutter right-click
Temporary / dependent / when-changed breakpointsStop once, after another breakpoint, or when a value changedEditor right-click
Caller-filtered breakpoints ★Stop only when a given method is a callerEditor right-click
Break on value changeStop at the line that changes a field or variableVariables right-click
Exception breakpointsStop on thrown / unhandled exceptions, filtered by type; or check the types in a listBreakpoints / Exception Settings view
UI freeze detection ★Pause where the UI thread is stuckAutomatic
Moving through code
Parallel Stacks, freezing threadsAll threads' stacks merged; keep a thread suspendedCall Stack right-click
Step Into TargetStep into one chosen call of the lineEditor right-click
Set next statementRun a line again or skip linesEditor right-click
Return valuesSee what the methods you stepped over returnedVariables / Autos
Looking at values
Hovers, inline values, DebuggerDisplay, AutosValues next to the code and in compact viewsEditor / Autos view
Pinned valuesKeep an expression at the end of a lineEditor right-click
Object IDsName an object ($1) and reach it from anywhereVariables / Watch right-click
Dump, table, image, C# initializer, string viewer, snapshotsRead and compare complex valuesVariables right-click
Time and performance
PerfTipsTime of the last step or continue at the lineAutomatic
Section timing, value trend ★Time a section or chart values on every pass, without stoppingEditor right-click
Memory / CPU graphPrivate Bytes, Working Set and CPU over timeCommand Palette
Heap snapshotsObjects per type on the GC heap, and what grew between two stopsCall Stack right-click / Command Palette
GDI / USER objects, handles, address space ★Catch GDI leaks and a full 32-bit address space before the app crashesCommand Palette
GDI leak candidates ★Fonts, brushes, bitmaps, icons and windows that were not disposed, and which keep growingHeap Snapshots panel
History and records
Step historyThe locals of every earlier stopStep History view
Exception log ★Every thrown exception, also the swallowed ones, with the stack and locals at the throwException Log view
Session report ★Markdown summary of the session for a bug reportCommand Palette
SQL log ★Every SQL statement run through ODP.NET / SqlClient / OleDb / Odbc with its parameter values and caller, also from your own data access componentSQL Log view
Capture evidence ★Pictures of the open forms, control values, variables, call stack and SQL as Markdown + PNG for a test reportCommand Palette / Call Stack right-click
Generate a unit test ★A test that replays the stopped method callCall Stack right-click
Source and symbols
Modules viewLoaded assemblies and whether symbols were foundModules view
Source in another folderFind source whose PDB path is not on this machinelaunch.json / settings
Source Link and symbol serversDownload the sources and PDBs of NuGet packagesAutomatic / Modules right-click
Debug decompiled assembliesStep into exes and DLLs without symbols as C#Automatic
WinForms
WinForms Controls viewThe control tree of the open formsWinForms Controls view
Highlight on screen ★Frame a control on the stopped formEye icon in the view
Break on a control event ★Stop in the handlers of a control's event, wherever they areWinForms Controls right-click
Change control propertiesChange text, visibility, colors, position or size while stoppedWinForms Controls right-click
Data bindings ★Every binding of a form with the value on each side; unconnected bindings and unsaved edits flaggedWinForms Controls view
Event trace ★Which control's event fired, in what order and how far apart, without stoppingWinForms Controls right-click
Starting a session
Attach, by name tooAttach to a running x86 app, or wait for it to startlaunch.json

Breakpoints, logpoints and hit counts

Right-click the gutter (left of the line numbers) to add a breakpoint, a conditional breakpoint or a logpoint. To change an existing one, right-click its dot and choose Edit Breakpoint.

12 for (int i = 0; i < orders.Count; i++) Hit Count ▾ %100 stop on every 100th pass 14 total += orders[i].Amount; Log Message ▾ i={i} total={total} in $FUNCTION print without stopping
The hit count and the log message are typed into the box that opens under the line.
KindWhat to typeBehavior
Conditionorder.Amount > 1000Stops only when the expression is true.
Hit count5 or ==5, >=5, >5, %5Stops on the 5th pass / from the 5th / after the 5th / on every 5th pass.
Logpointi={i} total={total} in $FUNCTIONWrites the message to the Debug Console and keeps running. {expression} is evaluated; $FUNCTION and $TID are the method name and thread id.
Use case: a bug appears only around the 300th order of a batch. Set a hit count of >=300 instead of pressing F5 three hundred times, or add a logpoint to print each order's total and look for the first wrong one.

Temporary, dependent, when-changed and caller breakpoints

Right-click a line in a C# editor. These are ordinary breakpoints with a marker in their condition, so they show in the Breakpoints view and can be edited or removed like any other.

21 order.Status = Recalculate(order); 22 Save(order); Go to DefinitionFind All References Add Temporary BreakpointAdd Dependent Breakpoint...Add Breakpoint When Value Changes...Add Breakpoint Filtered by Caller... Pin Value to Line...
The commands are at the bottom of the editor context menu.
CommandCondition it setsBehavior
Add Temporary Breakpoint#onceStops once, then the breakpoint removes itself.
Add Dependent Breakpoint...#after Orders.cs:42Does nothing until the program has stopped at the breakpoint you pick; from then on it stops normally.
Add Breakpoint When Value Changes...#changed order.StatusEvaluates the expression every time the line runs and stops only when the value differs from the previous time. The old and new values are written to the Debug Console.
Add Breakpoint Filtered by Caller...#caller Import.RunStops only when one of the methods is on the call stack (!Import.Run: unless it is). While stopped, the current call stack is offered.

The markers can be typed into any breakpoint's condition and combined with a hit count.

Use case: Save() is called from many places, but the bug only happens after an import. Put a breakpoint in the import, then a dependent breakpoint in Save() on it: you stop only in the saves that follow an import.
#caller Import.Run ← the breakpoint's condition in Orders.Save Import.Run() Orders.Save() MainForm.OnSave() Orders.Save() stops runs on without stopping Import.Run is on the call stack Import.Run is not on the call stack
The same line, reached from two places: only the call that comes through Import.Run stops.
Use case: a shared helper such as Save() runs hundreds of times when the screen opens, but the bug is in the import. Instead of a dependent breakpoint you would have to arm first, put #caller Import.Run on the line in Save(): it stops only in the calls the import makes.

Seeing values

Pinned values

Right-click a line and choose Pin Value to Line... to keep an expression at the end of that line. It is evaluated again in the selected stack frame every time the program stops, so you can watch a value next to the code instead of in the Watch view. Pins are kept with the workspace. Remove them with Unpin Value from Line or .NET x86: Clear All Pinned Values.

30 foreach (var line in invoice.Lines) 📌 invoice.Total = 1280.50 📌 invoice.Lines.Count = 4 32 invoice.Total += line.Amount;
Two pinned expressions on line 30, updated at every stop.

Return values

After Step Over or Step Out, the values returned by the methods that were called are shown at the top of the Variables and Autos views — no need to store them in a temporary variable first. A line with several calls shows each of them.

▾ VARIABLES ▾ Locals Program.Square returned: 9 Program.Square returned: 16 a: 25 ▸ list: Count = 3 int a = Square(3) + Square(4); // F10
After stepping over a line that calls Square twice.
Objects can be expanded; their text is the type name (DebuggerDisplay is not applied to them). The values are shown only at the stop right after the step and disappear on the next step or continue. Calls that end at a breakpoint inside them are not shown, nor are methods returning decimal, DateTime, Nullable<T> or a struct larger than 4 bytes (on x86 these values travel through a hidden buffer).
Use case: if (IsValid(order) && HasStock(order)) takes the wrong branch. Step over it and read which of the two returned false.

Variables view commands

Right-click a variable in the Variables view while stopped:

▾ VARIABLES ▾ Locals ▸ orders: Count = 8 total: 450 ▸ json: "{\"name\":\"Alice\"…" Set ValueCopy ValueAdd to Watch Break on Value Change Dump VariableView as TableCopy as C# Initializer View String · Take Snapshot · Compare… added by this extension
The commands under the separator come from this extension; “Break on Value Change” is VS Code's, made to work here.
CommandWhat it doesTypical use
Dump VariableOpens the whole object as JSON in an editor. List / Dictionary are shown as their items.Read a deep object at once, search it with Ctrl+F, paste it into an issue.
View as ImageShows a System.Drawing Image, Bitmap or Icon as a picture, with zoom and its size and pixel format.See what a chart or a scanned page looked like at that moment, before it was drawn on screen.
View as TableShows a List<T>, array, Dictionary or DataTable as a sortable, filterable table; copy or save as CSV.Check 500 rows loaded from a database; sort by amount to find the odd one.
Copy as C# InitializerCopies the value as C# code: new Order { Id = 1, Customer = "A", … }.Turn the data that caused a bug into a unit test.
View StringOpens a string pretty-printed as JSON, XML, HTML or plain text.Read an API response or a generated XML file held in a variable.
Take Snapshot / Compare with SnapshotRecords the value, then shows a diff against its current value.See what one button click changed in a settings object.
orders Filter rows Copy CSV Save CSV... 8 of 8 rows IndexIdCustomerAmount ▼Date 78Customer C1002026/11/08 67Customer B87.52026/11/07 56Customer A752026/11/06 …
View as Table: click a header to sort (numbers are compared as numbers).

Break on value change

Right-click a field, property or local in the Variables view and choose Break on Value Change. Execution stops right after the value changes and the reason shows the old and new value.

14_value++; 15} Paused on data breakpoint _value: 0 → 1
Stopped on the line after the write, showing old → new.
How it works and its limits. It is not a hardware data breakpoint: the extension finds the lines of your workspace's C# files that assign the name (x = …, x += …, x++), checks the value before and after each of them, and stops only if it changed. Writes through ref / out, from another object (other.x = …) or from code outside the workspace are not detected; the same name is watched for every instance.
Use case: a status field “suddenly” becomes Cancelled and you do not know who sets it. Break on value change takes you straight to the line.

Set next statement

While stopped, right-click a line of the method that is executing and choose Jump to Cursor. The yellow arrow moves there without running the lines in between — run a line again after fixing a value, or skip a call you do not want.

Only lines inside the executing method can be targets, and the runtime refuses moving into or out of a catch / finally block; you then get a message explaining why.

Use case: a calculation went wrong. Change an input with Set Value in the Variables view, jump back to the calculation line, and step over it again — no restart needed.

Parallel Stacks and freezing threads

Right-click in the Call Stack view and choose Show Parallel Stacks to see all threads' stacks merged into boxes (callers at the bottom, with the number of threads per box). Right-click a thread and choose Freeze Thread to keep it suspended while the others run; Thaw Thread lets it go again.

Use case: the app hangs with several workers. Parallel Stacks shows two threads waiting in Monitor.Enter under different callers — a deadlock. Freeze one worker to check whether the other then finishes.

Step into a specific call

On a line such as Outer(Inner1(), Inner2()), right-click and choose Step Into Target, then pick the call. The other calls run without stopping. The calls are listed in the order they run; if the picked one is not called after all, the step ends on the next line.

7 var total = Outer(Inner1(1), Inner2(2)); Step Into Target Inner1 Inner2 Outer runs 1struns 2ndruns 3rd (last) → stops at the first line of Inner2
The calls are listed in the order they run (arguments first). Picking Inner2 runs Inner1 without stopping.
Use case: Save(Validate(order), BuildAudit(user)) saves wrong data and you suspect Save. With Step Into you would first walk through Validate and BuildAudit and step out of each; Step Into Target → Save takes you straight there.

Exceptions

Use case: a screen shows empty data but no error. The Exception Log reveals a FormatException swallowed by an empty catch.

UI freeze detection

While the program runs, the extension checks a few times a second whether its UI threads still process window messages. When one has not for 2 seconds (netdbg.uiFreeze.thresholdMs), the program is paused on that thread: the Call Stack shows the code that holds the UI up, and the pause reads UI not responding for 2.0 s. Stops at breakpoints and steps never count. If the top frames are framework code (e.g. Thread.Sleep, a lock), select your own frame further down. Turn it off with netdbg.uiFreeze.enabled.

UI thread: does it answer window messages? (checked every 0.25 s) ✓✓✓ ✗✗✗✗✗✗✗✗✗ answering busy: no answer 2.0 s Breakpoint stops and steps are not checked, so they never count as freezes. ▾ CALL STACK PAUSED: UI NOT RESPONDING FOR 2.0 S System.Threading.Thread.Sleep() OrderForm.LoadCustomers() OrderForm.cs 88 OrderForm.OnRefreshClick() OrderForm.cs 41 System.Windows.Forms.Control.OnClick() [Native Frames]
A click handler loads data on the UI thread; after 2 seconds without an answer the program pauses there.
  1. When the UI thread has not answered for netdbg.uiFreeze.thresholdMs (2 s), the program is paused on that thread.
  2. Pick the first frame of your own code below the framework frames: that is what holds the UI up.
Use case: the window turns white ("Not Responding") now and then. Just run the app under the debugger; when it happens, you are shown the loop or the blocking call on the UI thread.

Time and performance

PerfTips

After each step or continue, the stopped line shows ≤ 12 ms elapsed. Step over calls one by one to see which is slow.

Section timing

Right-click a line, choose Start Timer Here... and name it; right-click a later line and choose End Timer Here.... Every pass is timed without stopping and charted in the Value Trend view.

Value trend

Right-click a line, choose Track Value at This Line... and enter expressions such as total; items.Count. Each pass records the values without stopping and charts them per expression.

Value trend total @ Program.cs:14 40 hits · 741 · min 0 · max 741 0800#1#40 ⏱ load (ms) @ Program.cs:30 12 hits · 84 · min 61 · max 212 0250#1#12
One small chart per expression; the spike in the timing chart is the slow pass.

Memory / CPU graph

Run .NET x86: Show Memory / CPU Graph to watch Private Bytes, Working Set and CPU usage once per second. Stopped periods are shaded. Set netdbg.memoryGraph.autoOpen to open it with every session.

Below them are two things Visual Studio does not chart: GDI / USER objects and handles (a process may hold 10,000 of each kind of object; the limit line appears past half of it), and the 32-bit address space in use against its 2 GB / 4 GB limit, with the largest free block. A warning appears at 80 % of the GDI / USER limit, and when the address space is 85 % full or its largest free block is under 128 MB.

Use case: after an hour of use the app draws red crosses and crashes. The GDI line climbs by a few objects every time a report is printed: a Font created in the print handler is never disposed.
Process memory and CPU Private Bytes (now)Working Set (now)CPU (now) 88.8 MB137.3 MB6.2 % Private BytesWorking Set 0 MB150 MB 0 %40 % CPU
Memory on top, CPU below; the gray bands are periods stopped at a breakpoint.
Use case: memory grows each time a form is opened and closed. Watch Private Bytes while repeating the action; if it never comes down, look for event handlers that are not removed.

Heap snapshots

While stopped, right-click in the Call Stack view and choose Take Heap Snapshot (or run .NET x86: Take Heap Snapshot): the number of objects and their bytes per type on the GC heap are listed, largest first, as in Visual Studio's Memory Usage. Take another snapshot at a later stop to see the change of each type (Δ Count, Δ Size); pick any two snapshots to compare, sort by a column, filter by name or show Increases only. A garbage collection runs right before each snapshot so that only objects still in use are counted (netdbg.heapSnapshot.collectGarbage, or the checkbox in the panel).

Heap Snapshots #2 10:42:15 — 4,120 objects, 236 KB #1 10:41:58 — 3,963 objects, 220 KB ☑ Increases only TypeCountΔ CountSizeΔ Size ▼ System.Windows.Forms.Button18+155.3 KB+4.4 KB string1,329+4293.6 KB+2.1 KB MyApp.OrderForm6+51.9 KB+1.6 KB System.EventHandler31+51.2 KB+200 B
After opening and closing the form five times, five more OrderForm instances are still on the heap: they are not released.

Above the types, GDI leak candidates lists the objects that hold a native resource (GDI+ fonts, brushes, pens, images, graphics, regions, paths; icons, cursors, windows), how many are not disposed — they still hold their handle — and the change since the snapshot compared with. A type whose Not disposed keeps growing is marked ⚠ leak candidate. Visual Studio cannot tell a disposed object from one that was not.

Use case: the GDI graph climbs while reports are printed. Take a snapshot, print three reports, take another: System.Drawing.Font shows Δ Not disposed +3. The print handler creates a font per page and never disposes it; a using fixes it.
Use case: the memory graph keeps rising. Stop, take a snapshot, open and close a form a few times, stop and take another. With Increases only, the form type is there once per time it was opened — something (often an event handler on a long-lived object) still holds it.

Step history

The Step History view keeps the locals of every stop (newest first). Values that changed since the previous stop in the same method are marked changed / new. Click an entry to open its location. It is a history to look at, not a way to run backwards.

When the program stops in a file that is not on this machine and the PDB has a Source Link map — most NuGet packages built from GitHub do — the file is downloaded and opened, so you can step through the package's real source. For a DLL without symbols, right-click it in Modules and choose Download Symbols to fetch its PDB from the NuGet / Microsoft symbol servers (from the next session). If no server has it, the debugger decompiles it.

Use case: a popular JSON library throws deep inside. Download its symbols, restart, and step into its code on GitHub at the exact commit the package was built from.

Debugging decompiled assemblies

An exe shipped without its PDB, or a DLL of the program whose source you do not have, is decompiled to C# by the debugger itself when you stop in it or step into it: the call stack points at the decompiled files, and breakpoints, stepping and locals work in the same session, with no .NET runtime needed. Methods that cannot be turned into C# are shown as IL. When the program has its PDB, a DLL without symbols is not your code: set "justMyCode": false to step into it. "decompile": "off" turns it off.

Use case: a third-party library throws ArgumentException from deep inside, and the message does not say which value it rejects. Turn Just My Code off, step into the call, and stop on the throw line: the locals show the value.

Object IDs

Right-click an object in Variables or Watch and choose Make Object ID. The object gets a name, $1, that reaches it from any method and any later stop: in Watch, the Debug Console and breakpoint conditions ($1.Count, order == $2). Values that are that object show {$1}. Like in Visual Studio, the ID does not keep the object alive.

Stop 1 — Orders.Total() ▾ VARIABLES lines = Count = 2 {$1} rate = 0.1 Make Object ID Copy Value Stop 2 — Cart.Add(), later ▾ WATCH $1.Count: 3 $1[2].Sku: "C-9" ▾ BREAKPOINTS Cart.cs 52 items == $1
The name reaches the same object from another method and a later stop.
  1. The object now shows {$1} wherever it appears.
  2. Watch $1 from any frame — here it has grown to 3 items.
  3. Use it in a condition: stop in Add only when it adds to this very list.
Use case: many carts exist, and one of them gets an item it should not. Make an object ID for the wrong cart when you first see it, then put items == $1 on the line that adds items: you stop only for that cart.

Generate a unit test from a stop

Right-click a frame in the Call Stack view and choose Generate Unit Test from Here. A test that calls the method again with its current arguments (and object) opens beside the editor, in the framework your projects use (xUnit, NUnit or MSTest). Fill in expected and save it in your test project. Stop at the first line of the method to capture the arguments as they came in.

▾ CALL STACK Orders.Total() Orders.cs 17 Program.Main() Program.cs 9 Generate Unit Test from Here Copy Call Stack Framework: from your projects (xUnit / NUnit / MSTest) Untitled-1 (C#) public class OrdersTests { [Fact] public void Total_ReplaysDebugSession() { // Arrange var sut = new Shop.Orders { Currency = "JPY" }; var lines = new List<Shop.Line> { new Shop.Line { … } }; var rate = 0.1M; // Act var result = sut.Total(lines, rate); // Assert var expected = default(decimal); // TODO Assert.Equal(expected, result);
The test opens unsaved beside the editor.
  1. Right-click the frame of the method to test.
  2. The object and the arguments are written as C# with the values they have now.
  3. Fill in the expected value and save the test in your test project.
Use case: a customer's order totals wrong. Reproduce it once under the debugger, stop in Total(), generate the test and fill in the right total: the bug is now a failing test, and stays covered after the fix.

SQL log

The SQL Log (.NET x86) view lists every SQL statement the program runs through an ADO.NET provider — ODP.NET (managed and unmanaged), SqlClient, OleDb and Odbc — without stopping: the statement, its parameter values, the caller and, expanded, the call stack. It hooks the provider, not your code, so statements run by a home-made data access component that wraps ODP.NET are logged too, with your method as the caller.

▾ SQL LOG ⇪ ⌫ ▾ 🛢 SELECT * FROM ORDERS WHERE CUSTOMER_ID = :id AND ORDERED >= :since OrderForm.LoadOrders · 10:42:15 id = 1001 number since = 2026-04-01 00:00:00.000 datetime ⨍ CustomerDal.GetOrders (no symbols) ⨍ OrderForm.LoadOrders OrderForm.cs:58 ⚠ SELECT NAME FROM ITEMS WHERE ITEM_ID = :id OrderForm.LoadLines · 10:42:16 · ×24 ▸ 🛢 UPDATE ORDERS SET STATUS = :s WHERE ORDER_ID = :id OrderForm.Save · 10:43:02
Click a statement to open it as a SQL document with the values filled in. ×24 with ⚠: the same statement ran 24 times — the usual shape of an N+1 problem.

Each statement pauses the program for a moment while it is read (about a few hundred milliseconds), so leave it off (netdbg.sqlLog.enabled) when timing. To log another provider, add its command type to netdbg.sqlLog.methods, e.g. Npgsql.NpgsqlCommand.ExecuteReader. The time a statement took is not recorded; ...Async methods are logged only where the provider calls its synchronous method.

Use case: a screen shows the wrong orders. Open the SQL Log, copy the statement with its values and run it in SQL Developer: the :since date is a day off, and the caller shows which method built it.

Session report

Run .NET x86: Export Debug Session Report (or click the button in the Step History view title) to open a Markdown summary of the last session: program, start / end time and exit code, every stop with the values that changed, the exceptions (with a count per type), section timings, tracked values and the modules with symbols.

Debug session report: Launch OrderApp Stops (step history) | # | Time | Function | Location | Changed values | | 2 | 18:41:48 | MainForm.OnButtonClick() | Program.cs:37 | _count = 1 | Section timings | load | Program.cs:12 | 2 | 80 | 100.0 | 120 |
Save it with the code, or paste it into a bug report or a pull request.

Capture evidence

While stopped, run .NET x86: Capture Evidence (Command Palette, Call Stack context menu, or the camera button in the WinForms Controls view title). Everything a test report needs from that screen goes into a new folder, evidence/<date-time>/ in the workspace (netdbg.evidence.folder), as evidence.md plus a PNG per form:

Reading the controls takes a few evaluations each: at most 300 controls are read per form, and the progress notification can cancel it.

Use case: a test case says “save with an empty customer: the error message is shown and nothing is written”. Stop on the message, capture evidence: the picture, the field values and the (absent) INSERT are in one Markdown file for the report.

Source in another folder

To step into your own library whose PDB records source paths that are not on this machine (e.g. a NuGet package you build elsewhere), add a parent folder of its source to sourceSearchPaths in launch.json (searched with subfolders), or replace a path prefix with sourceFileMap (e.g. { "/_/": "D:\\work\\MyLib\\" }). Both can also be set for every configuration in the settings (netdbg.sourceFileMap / netdbg.sourceSearchPaths). When a stop has no source here, the Debug Console says which path to map. For a library without symbols, see decompiling.

Path recorded in the PDB C:\agent\_work\3\s\MyLib\Calc.cs not on this machine sourceSearchPaths search under parent folders sourceFileMap replace a path prefix Your clone D:\work\MyLib\Calc.cs opens in the editor "sourceSearchPaths": ["D:\\work"], "sourceFileMap": { "C:\\agent\\_work\\3\\s": "D:\\work" } either one
Breakpoints you set in your clone are sent to the debugger under the PDB's path, and stops show your file.
Use case: your company's shared library comes as a NuGet package built on the CI server. Clone its repository, add the clone to sourceSearchPaths, and step into the library with its real source.

Modules

The Modules view lists the loaded assemblies and whether their symbols (PDB) were found. If a breakpoint stays hollow, check here that your assembly shows symbols loaded.

WinForms controls

While stopped, the WinForms Controls view (collapsed at the bottom of Run and Debug) shows the open forms and their controls as a tree: name, type and text, with hidden controls greyed out. Hover a control for its bounds, enabled state, dock and tab index. Right-click it to Dump Control or Copy Expression; the expression can be pasted into the Watch view.

▾ WINFORMS CONTROLS ⟳ ▾ 🗔 mainForm Form "Orders" ▾ ▭ panel1 Panel ▭ okButton Button "OK" ▭ nameBox TextBox "abc" ▭ status Label "Ready" (hidden) okButton — System.Windows.Forms.Button Bounds: {X=4,Y=4,Width=75,Height=23} Visible: true Enabled: true Dock: None TabIndex: 0 …OpenForms[0].Controls[0].Controls[0]
Children are read when you expand a node, so large forms stay quick to open.
Use case: a button “does not appear”. The tree tells you whether it exists, which panel it is in, and whether it is hidden or placed outside its parent's bounds.

Right-click a control and choose Break on Event... to list the handlers attached to its events, lambdas included, and stop in the ones you pick the next time the event fires — useful in old code where nobody knows which method handles the button.

Right-click a control and choose Change Property... to change its text, visibility, colors, position or size in the stopped program — try a fix without rebuilding. It shows on screen when the program continues. Dock and Anchor take member names (Fill, Top, Left).

Click the eye icon (Highlight on Screen) to frame a control on the screen: the form is shown in front, as it was when the program stopped, with a red frame, the control's name and its size for a few seconds.

▾ WINFORMS CONTROLS ▾ 🗔 mainForm Form ▾ ▭ panel1 Panel ▭ okButton Button "OK" 👁 Orders — ☐ ✕ OK okButton Button 75×23
Works while the program is stopped, even when the form is behind VS Code.
  1. Click the eye icon of a control in the WinForms Controls view.
  2. The form is shown in front as it was when the program stopped, with a red frame, the name and the size.

The link icon in the view title (Show Data Bindings), or the same command on a control, lists the data bindings of the open forms (or of that control and the ones inside it) — which Visual Studio cannot show. Simple bindings show the control property, the data source and member, the value in the control and the value in the current item side by side, the position in the list, the update mode and the format string; list bindings (ComboBox, ListBox, DataGridView) show DataSource, DisplayMember, ValueMember, the selected value and the position. ⚠ not connected marks a member that does not exist, ≠ differs a control that shows something else than its item holds.

Use case: the user edits a name, switches to another record, and the edit is gone. The table shows the text box ≠ differs from the item with the update mode OnValidation: the record changed before the box was validated, so the edit was never written back.
Use case: the tree says okButton exists and is visible, yet nobody can see it. Highlight it: the frame shows it sitting under another panel, or squeezed to a few pixels at the edge of the form.

Event trace

Right-click a control in the WinForms Controls view, choose Trace Events... and pick its event handlers (all are picked). Continue and use the form: the Event Trace (.NET x86) view lists every firing in order, oldest first — the event, the control that fired it (the handler's sender), the handler, the time and the gap to the previous firing. Nothing stops. Click an entry to open the handler; Export Event Trace writes the list to a text file; Clear Event Trace also stops tracing. Trace several controls to see how their events interleave. A handler you also set a breakpoint on still stops there.

Use case: typing in a field recalculates the total twice. The trace shows TextChanged of qtyBox, then Validating, then SelectedIndexChanged of priceCombo set by the first handler — the chain that runs the calculation again.

Attaching to a running app

Use an attach configuration. The process list shows only x86 .NET processes with their window titles; choose Show all processes... for everything else.

Select the x86 process to attach to OrderApp 12844 Orders — Main ReportViewer 9312 ☰ Show all processes...
Only processes the debugger can attach to are listed.

When an app is started by something else (a launcher, a scheduled task) and you need it from the very start, attach by name. Debugging waits until the process appears:

{
  "name": ".NET x86 Attach (wait for process)",
  "type": "netdbg",
  "request": "attach",
  "processName": "OrderApp",
  "waitTimeout": 120
}

Use cases

Legacy x86 dependency

Your WinForms app must stay 32-bit because of an old native DLL or COM component. Debug it in VS Code exactly like a 64-bit app.

“It just shows nothing”

Exception Log finds the exception swallowed by catch { }; click it to open the line.

Wrong value after many items

Track the value at the loop line, look at the chart, then set a hit count to stop right before it goes wrong.

Who changed this?

Break on value change stops at the line that modifies a field.

Is this slow?

Use PerfTips while stepping, then section timing to measure the suspicious part on every pass.

Reproduce a bug in a test

Copy as C# Initializer turns the live data into code for a unit test.

Check loaded data

View as Table shows the List or DataTable as rows; sort, filter, save as CSV.

App launched by another program

Attach with processName and debug it from its first moments.

Which call returned false?

Step over the condition and read the return values in Variables.

Where did my control go?

The WinForms Controls view shows its parent, bounds and visibility.

Write up a bug

Export the session report and attach it: stops, changed values and exceptions in one file.

UI freezes now and then

UI freeze detection pauses the program in the code that holds the UI thread.

Only from this caller

#caller stops a shared method only when a given method called it.

Skip to the call you care about

Step Into Target enters one call of a line and runs the others.

Follow one object

Make Object ID, then use $1 in Watch and conditions anywhere.

Turn a stop into a test

Generate Unit Test from Here writes the method call with the current values.

A library without source

Step into it: the debugger decompiles it to C#.

Library built on another machine

Point sourceSearchPaths at your clone.

Which SQL ran, with which values?

The SQL Log shows every statement with its parameters, also through your own data access layer; copy it with the values filled in.

Evidence for the test report

Capture Evidence saves the form pictures, field values and the SQL in one Markdown file.

Events fire in a strange order

Trace the controls' events and read the order and the gaps without stopping.

Troubleshooting

SymptomWhat to do
“… is a Windows PDB, which this debugger cannot read”Add <DebugType>portable</DebugType> to the .NET Framework project and rebuild.
The program runs as 64-bit, but should be x86Set <PlatformTarget>x86</PlatformTarget> and point program at bin/x86/....
“The x86 dotnet.exe was not found”Install the x86 .NET runtime (for WinForms: .NET Desktop Runtime x86).
Breakpoint stays hollowCheck the Modules view: your assembly needs symbols loaded (Debug build, PDB next to the DLL).
Can’t step into your own library / “Source not found: …” in the Debug ConsoleIts PDB records a path that is not on this machine: add a parent folder of the source to sourceSearchPaths, or map the path prefix with sourceFileMap (and set justMyCode to false for a Release build).
The Variables view is missingIt may have been hidden or moved: run Run and Debug: Focus on Variables View.
Something else is wrongEnable netdbg.trace, reproduce, and attach the “netdbg” output to an issue.

Settings

SettingDefaultMeaning
netdbg.exceptionLog.enabledtrueRecord every thrown exception (slower for apps that throw very many).
netdbg.uiFreeze.enabled / thresholdMstrue / 2000Pause the program when its UI does not respond for this long (ms).
netdbg.perfTips.enabledtrueShow the elapsed time after steps.
netdbg.stepHistory.enabledtrueRecord every stop in Step History.
netdbg.memoryGraph.autoOpenfalseOpen the memory / CPU graph when debugging starts.
netdbg.heapSnapshot.collectGarbagetrueRun a garbage collection before each heap snapshot.
netdbg.dump.maxDepth / maxNodes3 / 2000Limits of Dump Variable and related commands.
netdbg.sourceFileMap / sourceSearchPaths(empty)Where the source of referenced assemblies is, for every configuration (merged with launch.json).
netdbg.tracefalseTroubleshooting log of the debugger communication.
netdbg.debuggerPath(empty)For x86 programs, use another build of the x86 debug engine (netdbg.exe) instead of the bundled one. netcoredbg is not supported.
netdbg.sqlLog.methodsODP.NET, SqlClient, OleDb, OdbcProvider methods the SQL log reads commands at (Namespace.Type.Method).
netdbg.evidence.folderevidenceWhere Capture Evidence saves (relative to the workspace folder).

Turning features off

Every feature is on by default (true). false removes its views, menu entries and commands, and stops the work it does in the background.

SettingFeature
netdbg.memoryGraph.enabledMemory / CPU / GDI graph (no sampling at all)
netdbg.inlineValues.enabledInline values
netdbg.autos.enabledAutos view
netdbg.modules.enabledModules view, Download Symbols
netdbg.exceptionSettings.enabledException Settings view (and stopping on the types checked in it)
netdbg.winforms.enabledWinForms Controls view and its commands, Show Data Bindings
netdbg.heapSnapshot.enabledHeap Snapshots and GDI leak candidates
netdbg.parallelStacks.enabledParallel Stacks, Freeze / Thaw Thread
netdbg.valueTrend.enabledValue trend and section timing
netdbg.pinnedValues.enabledPinned values (kept, shown again when turned back on)
netdbg.breakpointCommands.enabledThe breakpoint commands of the editor context menu (the #once / #after / #changed / #caller conditions keep working)
netdbg.variableTools.enabledVariables / Watch context menu commands (Dump, View as Table / Image, Copy as C#, View String, snapshots, Object ID)
netdbg.generateTest.enabledGenerate Unit Test from Here
netdbg.sessionReport.enabledExport Debug Session Report
netdbg.stepHistory.enabledStep History view and recording
netdbg.exceptionLog.enabledException Log view and recording
netdbg.perfTips.enabledPerfTips
netdbg.uiFreeze.enabledUI freeze detection
netdbg.sqlLog.enabledSQL Log view and recording
netdbg.eventTrace.enabledTrace Events and the Event Trace view
netdbg.evidence.enabledCapture Evidence
netdbg.sourceLink.enabledSource Link downloads

netdbg · MIT License · GitHub