问题是这样的:
- 我拿了 IP 摄像机模拟器的源代码(https://github.com/inspiredtechnologies/IP-Camera-Emulator)
- 我组装了一个解决方案,其中一个项目(相同的 dll)在 C++ 中
成功构建后,我收到了应用程序和 c++ dll。我启动应用程序,添加一个视频文件并单击开始 - 我得到一个 DLLNotFoundException 错误,虽然这个 DLL 位于 exe 文件旁边
在应用程序中,导入执行以下操作:
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CreateRtspStreamerLib();
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void DestroyRtspStreamerLib(IntPtr lib);
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Int32 StartStreamLib(IntPtr lib, byte[] streamName, byte[] mediaPath, Int32 portNumber);
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void StopStreamLib(IntPtr lib);
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool GetStreamStatusLib(IntPtr lib);
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Int32 GetStreamRateLib(IntPtr lib);
[DllImport("RtspStreamerLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetVlcVersionLib(IntPtr lib);
实际上,如何解决问题?
我查看了 ProcMon,应用程序正在尝试加载 DLL,文件的路径是正确的,但是显示了一些调用,结果 FILE LOCKED WITH ONLY READERS