"Cannot Import dll" when importing C# DLL in Inno Setup

I know that this question has answer, but he does not help me. I saw articles: link and link, but I have problem. My code:

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 Setup:

[Files] 
Source: "GetDataBases.dll"; Flags: dontcopy 

[Code] 
function ServerOfDataBases(server, user, password: string; out strout: WideString): Integer; 
  external 'ServerOfDataBases@files:GetDataBases.dll stdcall'; 

I get this error

Cannot Import dll:C:Users...AppDataLocalTempis-ECJ5V.tmpGetDataBases.dll

Thank you for any idea.


Works for me, if I follow all the instructions from my answer to:
Calling .NET DLL in Inno Setup

So I would guess, that you didn't set the Platform target of your .NET/C# project to x86.

链接地址: http://www.djcxy.com/p/44528.html

上一篇: 非托管DLL无法加载到ASP.NET服务器上

下一篇: 在Inno安装程序中导入C#DLL时,“无法导入dll”