【发布时间】:2021-07-17 18:05:55
【问题描述】:
我正在尝试从 Delphi 6 调用 .NET DLL。
使用LoadLibrary()动态加载DLL工作正常,并返回句柄。
Handle := LoadLibrary(PChar(DLLName));
但是,GetProcAddress() 函数正在返回 nil,即使 Handle 是有效的,并且函数 'DLL_Version' 存在。
GetProcAddress(Handle, 'DLL_Version');
DLL代码贴在下面
[Guid("14fd1190-df04-488c-ab0f-b120ea3e3f3a")]
[ComVisible(true)]
public class UnManClass
{
[DllExport]
public static int DLL_Version()
{
return 251;
}
}
我已经使用UnmanagedExports nuget 包来支持 C# 中的 [DllExport]。
这是 DumpBin 的输出:
有什么方法可以解决这个问题,或者有什么替代方法可以解决吗?
【问题讨论】:
标签: c# .net delphi com delphi-6