首页 > 解决方案 > 在 Hololens 上的 C# Unity 中找不到模块 C++ .dll

问题描述

我正在尝试为我的项目实现一个简单的 .dll,该项目将为 HoloLens 增强现实应用程序构建。我试图简单地从我的 C++ .dll 调用一个函数来实现 OpenCV 代码,但在 HoloLens 上它会引发如下所示的错误。

.dll C++ 代码:

extern "C" void __declspec(dllexport) __stdcall test() {
    return;
}

统一 C# 代码:

 internal class OpenCV
    {
        // Define the functions which can be called from the .dll.
        [DllImport("Project1")]
        internal static extern void test();

        public static void testmeth()
        {
            test();
        }
    }

使用 Visual Studio 在 HoloLens 上调试时出错:

System.DllNotFoundException: 'Unable to load DLL 'Project1': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

在这里您可以看到 dll 的设置和路径: 在这里你可以看到dll的设置和路径

标签: c#c++unity3ddllhololens

解决方案


问题:我为 x86 编译并成功用于我的 UWP 应用程序的 OpenCV 源文件不知何故不适用于 HoloLens。

已解决:我为我的 C++ .dll 使用了 NuGet-Package“OpenCV-HoloLens”,并将 .dll 也复制到了 Unity。


推荐阅读