[英]32 bit unmanaged dll in 64 bit wrapper
我正在通過加載 32 位非托管 dll 創建一個包裝器以在 64 位環境中執行。 所以我的方法使用了這個LegacyWrapper
[LegacyDllImport("ste.dll")]
public interface INativeMethods : IDisposable
{
[LegacyDllMethod(CallingConvention = CallingConvention.Winapi)]
IIntPtr ste_init_with_environment_info(string dirLocation, string language);
}
我正在調用這個方法如下
public IWrapperConfig Configuration
{
get
{
return _configuration ??= WrapperConfigBuilder.Create().TargetArchitecture(TargetArchitecture.X86).Build();
}
}
using var client = WrapperProxyFactory<INativeMethods>.GetInstance(Configuration);
_steHandle = client.ste_init_with_environment_info(steHomeDirectory, SystemProperties());
它似乎毫無例外地有效,但是。 當我調用 function 時,結果是0x0000000000000000
應該類似於0x0186ad58
是什么導致了問題?
更新
當我看到 LagacyWrapper 的源代碼時,使用System.Runtime.Serialization.IFormatter
看到如下的序列化和反序列化
public void SendCallRequest(CallData callData)
{
_formatter.Serialize(_pipe, callData);
}
public CallResult ReceiveCallResponse()
{
CallResult callResult = (CallResult)_formatter.Deserialize(_pipe);
if (callResult.Exception != null)
{
throw callResult.Exception;
}
return callResult;
}
我對 LegacyWrapper 不是很熟悉,所以這是基於猜想。
從介紹 Legacy 包裝器的博文中:
由於我們無法將 32 位代碼加載到 64 位進程中,因此我們的想法是為此任務創建一個單獨的可執行文件。 它會以某種方式加載一個庫,調用一個特定的 function 並將結果傳回給調用者。
由於您的庫在另一個進程中運行,因此返回指向 memory 的指針可能不起作用。 據我所知,沒有一般方法可以知道指針指向多少有效 memory,那么包裝器如何知道要復制多少 memory? 這可能可以解決一些特殊情況,但我找不到任何關於序列化過程細節的文檔。
您可能能夠定義指針應該編組到結構。 否則,您可能希望在 legacyWrapper 項目頁面上發布問題,以澄清文檔(如果沒有其他內容)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.