Skip to main content
Version: Torizon OS 6.x.y

.NET Uno Development and Debugging on Torizon Using Visual Studio Code

Introduction

This article explains how to run and debug .NET Uno Applications on Torizon OS 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.

Prerequisites

Create a New Project

Press F1 on Visual Studio Code and then type Torizon/.NET: Create .NET Core Application to create an application:

Creating a .NET Core Application

After creating it write the application name on the same command bar:

Naming your .NET Core Project

Select a folder on system to store the project files:

Selecting project folder

After the folder selection, select the .NET Uno Application as the type of project:

Selecting project type

Then, choose the right target architecture of your board:

Selecting target architecture and .NET version

Type torizon on the username label:

Set Username

A .NET Core Uno project with the following files will be created:

.NET Core Uno project

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

caution

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:

IntelliSense

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:

Fullscreen

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:

caution

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;
GtkHost.Window.Fullscreen();
}

Known Issues

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.

Webinars

Embedded Linux and Microsoft Technologies: Graphical Interface Development - C#, .NET and VS Code (Brazilian Portuguese)



Send Feedback!