Invoking C++ dll in Blazor client App

Posted 3 years ago by lokhandesonal
0

Hello All,

 

I am trying to invoke C++ DLL in my client webassembly blazor application . However, I am not able to succeed in this.

I am using the following syntax to invoke the dll , however receiving error . 

Can anyone help me is Blazor webassembly is supporting invocation of C++ native dll in the client C# code 

following is the syntax to call dll from app.

 

       [DllImport("SampleDll.dll", CallingConvention = CallingConvention.Cdecl)]

       public static extern int Add(int a, int b);

 

Thanks

Sonal 

  • 0

    Maybe these links will be helpful: 

    https://github.com/dotnet/aspnetcore/issues/15765

    https://github.com/mono/mono/issues/8007

    I've never tried this, but it sounds like you might have some luck if you compile it to WebAssembly first, then invoke it through JS Interop. These links are kind of old though, so things could have changed.

    Also, if this doesn't help, it may be easier for someone to answer if you provide the error message. If you're not seeing a detailed error message, you can adjust your Program.cs file to display detailed errors

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>()
                .UseSetting(WebHostDefaults.DetailedErrorsKey, "true");
            });
    Posted 3 years ago by selliott
Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 0
An error has occurred. This application may no longer respond until reloaded. Reload 🗙