How can i load native dll in c# webassembly

574 views Asked by At

When i try use [DLLImport(nativeLib)] in c# WebAssembly and call that extern function i imported from native dll it gives me error in runtime

Here is the code and error

using System;
using System.Runtime.InteropServices.JavaScript;
using System.Runtime.InteropServices;

public partial class MyClass
{
    [DllImport("enet.dll")]
    public static extern int enet_initialize();

    [JSExport]
    internal static void Test()
    {
        Console.WriteLine("ENET: " + enet_initialize());//Gives error in runtime
    }
}

Uncaught    at MyClass.Test() in F:\TestWASM\TestWASM\Program.cs:line 23
   at MyClass.__Wrapper_Test_151838001(JSMarshalerArgument* __arguments_buffer) in F:\TestWASM\TestWASM\Microsoft.Interop.JavaScript.JSImportGenerator\Microsoft.Interop.JavaScript.JSExportGenerator\JSExports.g.cs:line 37
undefined

Here all i found from microsoft asp docs but id like to load from dll

0

There are 0 answers