-
Notifications
You must be signed in to change notification settings - Fork 16
Csharp Remote Debug Visual Studio
Since Horton runs (almost) all code that is being tested inside of Docker containers, it is useful to be able to remotely debug code that runs inside of containers. This procedure specifically involves using a Windows install of Visual Studio 2017 to debug the C or C# wrapper inside of a Linux container.
This is useful for:
- Catching exceptions inside of tests inside of debuggers
- Tracing through C/C# SDK code or C/C# glue code
Instructions for this are in remote-debug-setup.md
When you are completed with these steps, you should be able to SSH into your module container via your host machine (as opposed to your local VM, which the container is running on).
For C, you need to install the Visual C++ for IoT Development into your Visual Studio 2017 install
For C#, you don't need to install anything extra.
In this step, we take the host name, port, and SSH key that we got in Step 1 and put them into Visual Studio
- On Visual Studio, select
Tools->Options. - In the Options page, select
Cross Platform->Connection Manageron the left. - Click
Add, then enter the following values:
-
Host Name: The name of your linux VM. -
Port: The SSH port for your container (from step 1) -
User nane:root -
Authentication type:Private Key -
Private key file: The private key file for your container (from step 1)

**If you see an error titled Downloading and updating headers for IntelliSense**: Hit Close`. It's OK to ignore this.
- In Visual Studio, select
Debug->Attach to Process - In the
Attach to Processdialog, selectConnection Type=SSH - In the
Connection targetdropdown, select the SSH connection you created in Step 2
- Select the process with ID = 1 and click "Attach"
- In the
Select Code Typedialog, selectNative (GDB)for C orManaged (.Net Core for Unix)for C#
- You should see output in the Debug pane if you're successful.
- Break into the debugger.
- If it asks you to find source, find the file (probably
/wrapper/Program.cs) in the source that you downloaded in step 1. - If it doesn't ask you to find source, click the stack frame at the bottom of the stack (probably
/wrapper/Main.cpp) and find that file in the source you downloaded in step 1.
- If it asks you to find source, find the file (probably
After this, you can press F5 to continue and debug as usual (set breakpoints, etc)
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.