1

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?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Shouldn't you use the 64-bits package in that case? http://www.cygwin.com/packages/x86_64/cabextract/ – rene Apr 24 '14 at 08:18
  • Thanks rene...I have gone through that but I am not able to how to get that source? There is no download option to get source. –  Apr 24 '14 at 08:21
  • Hmmm, and if you get the source from the main page and compile that yourself? – rene Apr 24 '14 at 08:26
  • @downvoter : Please leave a comment before downvote... –  Apr 24 '14 at 08:26
  • Voting is anonymous...you have to live with that. Although your question is not terrible bad your last bullet asks for an off-site-resource which makes your question a close candidate. If you add that you tried to download the source and compile that for x64 you might reverse that downvote... – rene Apr 24 '14 at 08:30

1 Answers1

1

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490