Debug VC Code without Source Code¶
Debugging VC source code is sometimes necessary, since the preferred mode of operation is to work with VC as precompiled binary components when the source is not available.
This section describes the techniques related to debugging that enhance development productivity while working with VC and third-party components:
- Debugging VC components with using Source Link technology.
- Loading a PDB directly from public symbol servers.
The example below demostrates debugging a third party NuGet package without having acceess to the source code of the library and the local project that references it as a package.
Debug with Source Link¶
Note
Source Link technology facilitates .NET assembly debugging of NuGet packages by embedding source control metadata inside the assemblies and package during their creation. This enables developers to debug the package's source code by stepping into it using Visual Studio, provided they have enabled Source Link.
Source Link is the preferred way to debug the VC components because:
- All VC platform and modules components already support the Source Link technology.
- You can step into framework methods as if you were debugging with your own code.
- You can inspect all variables and set breakpoints.
To start using Source Link for debugging:
-
Configure Visual Studio to support NuGet.org symbol sources:
- In Visual Studio, go to Tools > Options > Debugging > Symbols.
- Check NuGet.org Symbol Server to allow VS load symbols from public NuGet servers.
- Select the option Load only specified modules to speed up the launch of a debug session.
-
Configure Visual Studio debugging general options:
- In Visual Studio, go to Tools > Options > Debugging > General.
-
Select the options according to the screenshot:
- Uncheck Enable Just My Code to allow stepping into third-party code.
- Uncheck Enable .NET Framework source stepping not to prevent debugging .NET classes.
- Check Enable source server support to enable loading symbols from public places.
- Check Enable Source Link support to activate Source Link.
-
Step into third-party code:
-
Set the breakpoint in our code in the line where we call '_searchService.SearchCustomerOrdersAsync'.
-
When the debugger hits that line, press F11 or use the Step Into functionality to download the VirtoCommerce.OrderModule.Data source code via Source Link.
-
Accept downloading from Github to view the source code for that specific version of your package.
-
Now you can continue debugging the third-party module as it is included into your solution as source code.
Load PDB from Public Symbol Servers¶
If the third-party component doesn't support Source Link and you haven't loaded the PDB file for the library:
-
Go to Debug > Window > Modules and load symbols of Newtonsoft.Json library manually.
-
Step into this library and continue debugging process.