[英]How can I call mixed mode C# dll from Delphi using BTMemoryModule?
I have a DLL written in C# that uses Robert Giesecke's UnmanagedExports library and exports functions with [DllExport]
. 我有一个用C#编写的DLL,它使用Robert Giesecke的UnmanagedExports库并使用
[DllExport]
导出函数。
I can load it fine with LoadLibrary
, and call its exported functions. 我可以使用
LoadLibrary
很好地加载它,并调用其导出的函数。 When I tried to load it into memory using BTMemoryModule
, the call of entry point (DllMain - DLL_PROCESS_ATTACH) TDllEntryProc
(in function BTMemoryLoadLibary
) returns false. 当我尝试使用
BTMemoryModule
将其加载到内存中BTMemoryModule
,入口点(DllMain-DLL_PROCESS_ATTACH) TDllEntryProc
(在BTMemoryLoadLibary
函数中)的调用返回false。 How can I load such a DLL using BTMemoryModule
. 如何使用
BTMemoryModule
加载此类DLL。
Loading DLLs from memory is not unsupported. 不支持从内存加载DLL。 Any code that does this is using unsupported hacks to do so.
任何执行此操作的代码都使用不受支持的黑客来执行此操作。 The system provides
LoadLibrary
, LoadLibraryEx
etc. to perform this task, and they require the DLL to be present on disk. 系统提供
LoadLibrary
, LoadLibraryEx
等来执行此任务,并且它们要求DLL存在于磁盘上。
Your DLL is a mixed mode .net assembly, and it requires special treatment by the loader. 您的DLL是混合模式的.net程序集,它需要加载程序进行特殊处理。 The system loader, as invoked by calls to
LoadLibrary
, LoadLibraryEx
etc. knows how to perform the actions needed to load a mixed mode .net assembly. 通过调用
LoadLibrary
, LoadLibraryEx
等调用的系统加载器知道如何执行加载混合模式.net程序集所需的操作。 The BTMemoryModule code does not perform these special actions. BTMemoryModule代码不执行这些特殊操作。
If you are going to be able to load such a module from memory, you will need to either find a library that supports such modules, or write your own loader code. 如果要能够从内存中加载这样的模块,则需要找到一个支持此类模块的库,或者编写自己的加载器代码。 Frankly, I doubt that such a library exists.
坦白说,我怀疑这样的图书馆是否存在。 More realistically you should load the DLL from disk.
实际上,您应该从磁盘加载DLL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.