I would like to write some of my application logic in C# and be able to update (sideload) it after deploying the host application. Since WASM support has further improved with .NET 8, I considered to package up my application code into a WASM module and execute it securely in a WASM sandbox. I specifically don't require WASI support which could introduce security issues.
Is that at all possible with the current wasm-tools workload or other tooling?
How would I annotate C# functions to be exported from the WASM module?
Is there a minimal working example that replicates e.g. this gct.wat code in C#? https://docs.wasmtime.dev/examples-c-gcd.html
I tried to use the wasmconsole
and wasmbrowser
project templates but both of them yield .wasm
modules that have dependencies on additional external functions from either the browser or wasi interfaces.
Its experimental, but https://github.com/dotnet/runtimelab/blob/feature/NativeAOT-LLVM/docs/using-nativeaot/compiling.md#webassembly will build plain wasm modules. To export functions, use UnmanagedCallersOnly
attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With