# Loading Blazor and Revolt Wasm in the Same Page

**URL:** <https://revolt.metaeducation.com/forum/t/loading-blazor-and-ren-c-wasm-in-the-same-page/1611>\
**Category:** Language Bridging\
**Created:** [May 18, 2021, 1:05pm UTC](https://revolt.metaeducation.com/forum/t/loading-blazor-and-ren-c-wasm-in-the-same-page/1611 "2021-05-18T13:05:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![hostilefork](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/hostilefork/32/421_2.png) [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Post date:** [August 22, 2024, 3:59am UTC](https://revolt.metaeducation.com/forum/t/loading-blazor-and-ren-c-wasm-in-the-same-page/1611/2 "2024-08-22T03:59:06Z")

</div>

I was a bit impressed with how well Blazor was working 3 years ago for how new it was. They'd done a pretty good job of making the "DLLs of WebAssembly" (side modules) which I haven't yet gotten a grip on. And their Wasm files for the various modules were surprisingly small.

But it seems in the intervening years, Blazor has gained a fair bit of momentum. A friend of mine is using it and sings its praises. He's using this:

> **[Blazorise - Blazor Component Library](https://blazorise.com/)**
>
> Battle-tested since 2018 and actively maintained. Build with 100+ Blazor components, your choice of CSS framework, flexible theming, and commercial support.

I don't like going off on random tangents when there's still lots of design issues to hammer out. But providing Rebol services to C# running in the browser could be aligned with the browser-focus mission.

While I used C# right about when it came out for a few things, I've forgotten just about all I knew. And even if I did remember it I imagine it's quite different now (and more different if you're using Blazor). So I don't really know what the story is on variadics.

But we live in the age of AI!

I asked ChatGPT if it could handle it, and it says yes... there are variadics and everything can be considered an object, including string literals:

```
using System;

class Program
{
    static void someFunction(params object[] args)
    {
        foreach (var arg in args)
        {
            Console.Write($"{arg} ");
        }
        Console.WriteLine();
    }

    static int makeInt(int i) => i;

    static void Main()
    {
        // prints "1 hello world 2"
        someFunction(1, "hello", "world", 2);

        // prints "hello 1"
        someFunction("hello", 1);

        // prints "1 hello world 2"
        someFunction(makeInt(1), "hello", "world", makeInt(2));
    }
}

```

C# apparently uses UTF-16 internally (losers!) but you can convert the literal strings to UTF-8:

```
using System;
using System.Text;

class Program
{
    static byte[] StringToUtf8(string str)
    {
        return Encoding.UTF8.GetBytes(str);
    }

    static void Main()
    {
        string myString = "hello";
        byte[] utf8Buffer = StringToUtf8(myString);

        // Pass utf8Buffer to WebAssembly function...
    }
}

```

Here's how you set up Blazor to call JavaScript (which will call the WebAssembly export).

```
@inject IJSRuntime JS

@code {
    private async Task CallWasmFunction()
    {
        string myString = "hello";
        byte[] utf8Buffer = Encoding.UTF8.GetBytes(myString);

        // Pass the buffer to the JS function
        await JS.InvokeVoidAsync("callWasmFunction", utf8Buffer);
    }
}

```

## Seems Very Promising...

Given the advancements in CSCAPE and all the information about the API already being captured structurally (enough to spit out the C/C++ and JavaScript interface code), adding C# might not be difficult at all.

So maybe if I get bored or blocked I'll hack this up.

---

_[View the full topic](https://revolt.metaeducation.com/forum/t/loading-blazor-and-ren-c-wasm-in-the-same-page/1611)._
