在我的 Unity 项目中,我有 2 个版本的自定义 DLL,一个用于 x86,另一个用于 ARM64(分别用于 Unity 编辑器和目标设备)
x86 dll 按预期工作,但是当部署到我的 ARM64 设备 (Hololens 2) 时,我收到以下错误:
DllNotFoundException: Unable to load DLL 'OpenCV_ImageProcessing_ARM64'. Tried the load the following dynamic libraries: Unable to load dynamic library 'OpenCV_ImageProcessing_ARM64' because of 'Failed to open the requested dynamic library (0x06000000) - The specified module could not be found. (WinError:0000007e) at InspectionMenu.processCrack (UnityEngine.Color32[]& raw, System.Int32 width, System.Int32 height) [0x00000] in <00000000000000000000000000000000>:0 at InspectionMenu.Update () [0x00000] in <00000000000000000000000000000000>:0
DLL 的导入取决于正在运行的系统,这按预期工作。
#if UNITY_EDITOR
[DllImport("CrackDetection")]
public static extern void processCrack(ref Color32[] raw, int width, int height);
#else
[DllImport("OpenCV_ImageProcessing_ARM64")]
public static extern void processCrack(ref Color32[] raw, int width, int height);
#endif
我的两个 DLL 都位于
Assets/Plugins
文件夹中,并且名称是正确的。我已经研究了通过 Dependency 找不到 DLL 的其他依赖项的可能性,并将位于下图中的 ARM64 OpenCV DLL 添加到同一个 Assets/Plugins
文件夹中,但仍然没有成功。我不确定是否还需要添加 MSVCP140.dll
和 VCRUNTIME140.dll
但我不确定在哪里可以找到它们。
解决了这个问题,必须将
MSVCP140.dll
和VCRUNTIME140.dll
以及CONCRT140.dll
添加到插件文件夹中。这些都是在Visual Studio中可以找到的文件