Join our Discord server for community support and discussions Icon description

The .NET team has been hard at work with WebAssembly support, and while we’ve been having WebAssembly debugging from the browser, it’s now possible to debug an Uno WebAssembly app using Visual Studio 2019 16.6 Preview 1!

Debug an Uno Platform WebAssembly Web app with Visual Studio

Here’s what you need to do to debug an Uno application in Visual Studio:

<StackPanel> 
   <TextBlock x:Name="txt" 
              Text="Hello, world!" 
              Margin="20" 
              FontSize="30" /> 
   <Button Content="click" 
           Click="OnClick" /> 
</StackPanel>

 

public void OnClick(object sender, object args) 
{ 
  var dt = DateTime.Now.ToString(); 
  txt.Text = dt; 
}

 

"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",

 

This will instruct Visual Studio to connect to the browser through the .NET for WebAssembly debugger.

Now let’s debug the app:

  1. Place a breakpoint in the OnClick method
  2. Press F5
  3. Wait a moment for the breakpoint to become fully red

You’re now debugging in Visual Studio!

Debugger Features

In the supported debuggers features, viewing the stack trace is supported, as well as watch and locals:

 

Tooltips when hovering over variables :

 

And the most interesting of all, even though it was supported in the browser, Source Link support, when viewing frames of the stack that are in supported assemblies:

 

Syntax coloring is not yet available for these files, but it’ll most probably be coming in a future Visual Studio update.

 

Preview Bits and Next Steps

The Visual Studio integration is in its early days, and it’s bound to have some issues on the edges. For instance, it’s not possible to place a breakpoint in the entry point of the app (the Main method) and debugging PWA enabled apps is not working properly.

If you find issues, please let us know by opening one here.

If you are new to the Uno Platform, you may want to run through the Getting Started tutorial. This will ensure you have the correct environment set up and that you have the latest release of Uno. If you have already worked with Uno, you may want to update your Uno package via your Visual Studio NuGet package manager.

 

Uno Platform 5.2 LIVE Webinar – Today at 3 PM EST – Watch