简体   繁体   English

在64位C#应用程序中使用32位CabExtract库提取cab文件

[英]Extracting cab file with 32 bit CabExtract library in 64bit C# application

Recently, I am working in extracting cab file with CabExtract (written in C) in 64 bit C# application . 最近,我正在用64 bit C# application CabExtract (用C编写)提取cab文件。 The library works fine when it is run in 32 bit application but when same library used in 64 bit application, it throws following exception: 该库在32位应用程序中运行时运行良好,但是在64位应用程序中使用相同的库时,它将引发以下异常:

The importing from cabExtract.dll has been implemented in following way: 从cabExtract.dll导入已通过以下方式实现:

[DllImport("cabExtract.dll", EntryPoint="ExtractCabBegin", CharSet=CharSet.Unicode, ExactSpelling=true)]
internal static extern int ExtractCabBegin();

Exception : System.BadImageFormatException 异常:System.BadImageFormatException

Message :An attempt was > made to load a program with an incorrect format. 消息:试图加载格式错误的程序。 (Exception from HRESULT: 0x8007000B) (来自HRESULT的异常:0x8007000B)

I suspect the CabExtract library supports for 32 bit.But I have not found any CabExtract library for 64 bit. 我怀疑CabExtract库支持32位。但是我还没有找到64位的CabExtract库。 So, my question : 所以,我的问题是:

Will it able to use 32 bit unmanaged library from 64 bit managed application? 它将能够使用64位托管应用程序中的32位非托管库吗? If yes, how can it be done? 如果是,该怎么办?

Will it able to use 32 bit unmanaged library from 64 bit managed application? 它将能够使用64位托管应用程序中的32位非托管库吗? If yes, how can it be done? 如果是,该怎么办?

No this is not possible. 不行,这是不可能的。 64 bit processes can only load 64 bit modules. 64位进程只能加载64位模块。 32 bit processes can only load 32 bit modules. 32位进程只能加载32位模块。

The library you link to ships as source and is covered by the LGPL license. 您链接到的库作为源提供,并受LGPL许可证的保护。 So long as you adhere to that license you can compile the code into a 64 bit DLL and use that from your 64 bit process. 只要您遵守该许可证,就可以将代码编译成64位DLL,并在64位进程中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM