0

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

  • 1
    I wouldn't be surprised if you have problems with native dlls as the environment that they are running in (browser) is very different to the environment they're intended to run in. – phuzi Jun 22 '23 at 08:47
  • 1
    Does this answer your question? [Can C++ be called from C# compiled to wasm?](https://stackoverflow.com/questions/56466822/can-c-be-called-from-c-sharp-compiled-to-wasm) – Charlieface Jun 22 '23 at 09:30

0 Answers0