[英]C++ DLL in Blazor Project
I am trying to bring a small desktop application that I do in C # to Blazor.我正在尝试将我在 C # 中所做的小型桌面应用程序带到 Blazor。 But I am running into the wall of native dlls.
但是我遇到了原生 dll 的墙。
I have a dll of my own in C ++ that I am not knowing how to take to blazor.我在 C ++ 中有自己的 dll,我不知道如何将其带到 blazor。
Currently in desktop application I am using the following method目前在桌面应用程序中我正在使用以下方法
[DllImport(@"C:\Users\amg\source\CRVentaGenerica\CRVentaGenerica\bin\Debug\My.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int My_Initialize(string archivo);
I have been looking for information and / or examples but I have not found anything that is clarifying.我一直在寻找信息和/或示例,但我没有找到任何可以澄清的东西。
The error that the browser console tells me is "DLLNotFound".浏览器控制台告诉我的错误是“DLLNotFound”。
Any indication to be able to jump this wall?有什么迹象表明可以跳过这堵墙?
Thanks for your time <3.感谢您的时间<3。
The error that the browser console tells me
浏览器控制台告诉我的错误
When you see this in the Browser then you are using Blazor WebAssembly.当您在浏览器中看到此内容时,您正在使用 Blazor WebAssembly。 You can't use a native library there.
您不能在那里使用本机库。
You would have to a) compile the C++ to WebAssembly and then b) use JS Interop to load and call that.您必须 a) 将 C++ 编译为 WebAssembly,然后 b) 使用 JS Interop 加载并调用它。 I don't know about an example.
我不知道一个例子。
Blazor also has a server-side application type. Blazor 也有服务器端应用类型。 You could use the DLL there just as in the desktop app.
您可以像在桌面应用程序中一样使用 DLL。
3 solutions 3个解决方案
Example with ASP.NET Core here https://github.com/iso8859/ExposeCppApi此处以 ASP.NET 内核为例 https://github.com/iso8859/ExposeCppApi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.