Question

Recently, I am working in extracting cab file with CabExtract(written in C) in 64 bit C# application. 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:

The importing from cabExtract.dll has been implemented in following way:

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

Exception : System.BadImageFormatException

Message :An attempt was > made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

I suspect the CabExtract library supports for 32 bit.But I have not found any CabExtract library for 64 bit. So, my question :

Will it able to use 32 bit unmanaged library from 64 bit managed application? If yes, how can it be done?

Was it helpful?

Solution

Will it able to use 32 bit unmanaged library from 64 bit managed application? If yes, how can it be done?

No this is not possible. 64 bit processes can only load 64 bit modules. 32 bit processes can only load 32 bit modules.

The library you link to ships as source and is covered by the LGPL license. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top