Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

You can now use WebAssembly from .NET with Wasmtime!

Save for later
  • 3 min read
  • 05 Dec 2019

article-image

Two months ago, ASP.NET Core 3.0 was released with an updated version of the Blazor framework. This framework allows the building of interactive client-side web UI with .NET. Yesterday, Peter Huene, a staff research engineer at Mozilla shared his experience of using Wasmtime with .NET. He affirms that using this format will enable developers to programmatically load and execute WebAssembly code directly from their .NET programs.

Key benefits of using WebAssembly from .NET with Wasmtime

Share more code across platforms


Although .NET Core enables cross-platform use, developers find it difficult to use a native library as .Net Core requires native interop and a platform-specific build for each supported platform.

However, if the native library is compiled to WebAssembly, then the same WebAssembly module can be used across many different platforms and programming environments, including .NET. Thus a more simplified distribution of the library and applications will allow developers to share more codes across platforms.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime

Securely isolate untrusted code


According to Huene, “The .NET Framework attempted to sandbox untrusted code with technologies such as Code Access Security and Application Domains, but ultimately these failed to properly isolate untrusted code.” This resulted in Microsoft deprecating its use for sandboxing and removing it from .NET Core.

Huene asserts that since WebAssembly is designed for the web, its module will enable users to call the external explicitly imported function from a host environment and will also give access to only a region of memory given to it by the host. With WebAssembly, users can also leverage this design to sandbox code in a .NET program.

Improved interoperability with interface types


In August this year, WebAssembly’s interface types permitted users to run WebAssembly with many programming languages like Python, Ruby, and Rust. This interoperability reduced the amount of glue code which was necessary for passing complex types between the hosting application and a WebAssembly module.

According to Huene, if Wasmtime implements official support for interface types for .NET API in the future, it will enable a seamless exchange of complex types between WebAssembly and .NET.

Users have liked the approach of using WebAssembly from .NET with Wasmtime.

https://twitter.com/mattferderer/status/1202276545840197633

https://twitter.com/seangwright/status/1202488332011347968

To know how Peter Huene used WebAssembly from .NET, check out his demonstrations on the Mozilla Hacks blog.

Exploring .Net Core 3.0 components with Mark J. Price, a Microsoft specialist

.NET Framework API Porting Project concludes with .NET Core 3.0

Wasmer’s first Postgres extension to run WebAssembly is here!

Wasmer introduces WebAssembly Interfaces for validating the imports and exports of a Wasm module

Introducing SwiftWasm, a tool for compiling Swift to WebAssembly