"Cannot Import dll" 在 Inno Setup 中导入 C# DLL 时
"Cannot Import dll" when importing C# DLL in Inno Setup
我知道这个问题有答案,但他不帮我。我看到文章:link and link,但我有问题。我的代码:
C#:
[DllExport("ServerOfDataBases", CallingConvention = CallingConvention.StdCall)]
public static int ServerOfDataBases(
string server, string user, string password,
[MarshalAs(UnmanagedType.BStr)] out string strout)
{
string resultStr = String.Empty;
// ...
strout = resultStr;
return 0;
}
Inno 设置:
[Files]
Source: "GetDataBases.dll"; Flags: dontcopy
[Code]
function ServerOfDataBases(server, user, password: string; out strout: WideString): Integer;
external 'ServerOfDataBases@files:GetDataBases.dll stdcall';
我收到这个错误
Cannot Import dll:C:\Users...\AppData\Local\Temp\is-ECJ5V.tmp\GetDataBases.dll
谢谢你的想法。
如果我按照我的回答中的所有说明进行操作,对我有用:
Calling .NET DLL in Inno Setup
所以我猜,您没有将 .NET/C# 项目的 平台目标 设置为 x86.
有关从 DLL 返回字符串的更多信息,请参阅:
Returning a string from a C# DLL with Unmanaged Exports to Inno Setup script
我知道这个问题有答案,但他不帮我。我看到文章:link and link,但我有问题。我的代码:
C#:
[DllExport("ServerOfDataBases", CallingConvention = CallingConvention.StdCall)]
public static int ServerOfDataBases(
string server, string user, string password,
[MarshalAs(UnmanagedType.BStr)] out string strout)
{
string resultStr = String.Empty;
// ...
strout = resultStr;
return 0;
}
Inno 设置:
[Files]
Source: "GetDataBases.dll"; Flags: dontcopy
[Code]
function ServerOfDataBases(server, user, password: string; out strout: WideString): Integer;
external 'ServerOfDataBases@files:GetDataBases.dll stdcall';
我收到这个错误
Cannot Import dll:C:\Users...\AppData\Local\Temp\is-ECJ5V.tmp\GetDataBases.dll
谢谢你的想法。
如果我按照我的回答中的所有说明进行操作,对我有用:
Calling .NET DLL in Inno Setup
所以我猜,您没有将 .NET/C# 项目的 平台目标 设置为 x86.
有关从 DLL 返回字符串的更多信息,请参阅:
Returning a string from a C# DLL with Unmanaged Exports to Inno Setup script