发布后立即丢失 DLL。 .net 窗体

Dll is missing right after publishing it. .net WinForms

发布的项目安装后文件到哪里去了?我尝试将 DLL 放在安装文件夹中,但它仍然有同样的问题。

我正在尝试通过 pinvoke 使用 DLL

[DllImport("tc-b_new_sdk.dll", CallingConvention = CallingConvention.Cdecl)]

我收到此错误:

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

找不到 DLL 本身或其依赖项之一。

如果 DLL 与可执行文件位于同一目录中,则表明存在依赖关系问题。我们无法知道依赖项是什么。该信息应该随 DLL 一起提供。此错误的一个常见原因是您的程序无法解析对 DLL 链接到的 MSVC 的依赖性。

尝试像这样添加 DLL 的路径:

[DllImport("C:\Users\User\Desktop\tc-b_new_sdk.dll", CallingConvention = CallingConvention.Cdecl)]