2017-08-04 48 views
1

我知道这个问题有答案,但他不帮我。我看到文章:linklink,但我有问题。我的代码:当在Inno Setup中导入C#DLL时,“Can not Import dll”

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 '[email protected]:GetDataBases.dll stdcall'; 

我得到这个错误

无法导入DLL:C:\用户\应用程序数据\ Local \ Temp \ is-ECJ5V.tmp \ GetDataBases.dll

谢谢你的任何想法。

回答

0

工作对我来说,如果我遵循我的回答都说明:
Calling .NET DLL in Inno Setup

所以我猜,你没有设置平台针对您的.NET/C#项目x86

+0

您的文章非常好。它帮助了我。如果有人愿意从C#DLL中返回一个字符串,那么使用文章[link](https://stackoverflow.com/questions/20776847/returning-a-string-from-ac-sharp-dll-with-unmanaged-出口到INNO-设置-凭证)。 –

+0

对不起,我更正了我的评论。我的英语不好。 –

+0

@ДжирайяNp,如果您发现我的文章有帮助,请立即注册。 –