.NET Uno Development and Debugging on Torizon Using Visual Studio Code
This article explains how to run and debug .NET Uno Applications on TorizonCore using the Visual Studio Code extension provided by Toradex.
The goal is to show a GUI interface using .NET Core Uno template and being able to debug the code with breakpoints using the Torizon Visual Studio Code Extension.
This article complies with the Typographic Conventions for Torizon Documentation.
- Read the article Visual Studio Code Extension for Torizon.
- Pay special attention to the commands tab.
- Have one of the OS below:
- Windows 10 or 11 Pro / Enterprise / Education
- Linux (it was validated using Ubuntu 20.04)
- Toradex Hardware with TorizonCore installed.
- .NET SDK
- C# extension for Visual Studio Code
- Uno Platform extension for Visual Studio Code
Create a New Project
F1 on Visual Studio Code and then type
Torizon/.NET: Create .NET Core Application to create an application:
After creating it write the application name on the same command bar:
Select a folder on system to store the project files:
After the folder selection, select the
.NET Uno Application as the type of project:
Then, choose the right target architecture of your board:
torizon on the username label:
A .NET Core Uno project with the following files will be created:
Create a New Project - Video
Deploy and Debug
After configuring your project, you can now deploy and debug it. Since this is common to all languages supported by the extension, please refer to the section Deploy and Debug from the article Visual Studio Code Extension for Torizon.
Remote Hot Reload
To use the remote Hot Reload feature during a debug session, it is necessary to have performed the deploy and debug steps.
As shown in the video below, it is necessary that the Port and the Host IP are set to the appropriate values. Then, you can edit the
.xaml file been presented on the screen of target, save the changes and check the changes taking place in the application running:
Deploy and Release
After going through the process of deploying and debugging the application, you can now deploy and release it. Since this is common to all languages supported by the extension, please refer to the section Deploy and Release from the article Visual Studio Code Extension for Torizon.
Locally Debug and Hot Reload
It is also possible to run the application in Debug mode locally, on the development PC. In the Debug activity bar there are two target options. The default target
.NET Launch (Torizon) will deploy, debug and hot reload remotely, on a development board with Torizon. The target
.NET Launch (Skia Uno Platform) will run, debug and hot reload locally. Select it and press
F5 to start the debug session locally:
For intellisense to work correctly, every time something on the XAML file changes it is necessary to perform a build of the solution, to generate the XAML symbols. The video below shows a Text Block being altered and a new Button being added:
It is possible to enable the fullscreen mode on the application by adding the following lines in the
App.xaml.cs file, as shown in the video below:
Pay attention to the correct line numbers
09: using Uno.UI.Runtime.Skia;
10: using System.Runtime.InteropServices;
89: if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
(RuntimeInformation.OSArchitecture == Architecture.Arm ||
RuntimeInformation.OSArchitecture == Architecture.Arm64))
GtkHost.Window.Decorated = false;
At the time of this publishing (March 16th, 2022) there are two issues known by our team with the
v0.3 of the Uno platform extension for Visual Studio Code:
We have reported the issues and accordingly to the maintainers of the Uno platform extension for Visual Studio Code they are already working on it and hopefully in their next release they are both fixed.