Calling a 32-bit .NET dll from a 64-bit .NET application [modified]
-
I am developing a major application that (among other things) talks to SQL Server databases. I have it built with a platform target of "Any CPU". However, it has to be able to import legacy data from mdb databases. The Jet database engine is only available on the 32-bit platform. I have created a .NET assembly built with a platform target of "x86" for the main application to call to do the importing. The problem is that I get a
BadImageFormatException (0x8007000b)
when trying to load the dll when running 64-bit Vista. There seems to be a division of opinion about whether the 64-bit framework should be able to load 32-bit dlls. Does anyone have a definitive answer, or a solution to the problem? I really don't want to have to build the whole app to target 32-bit just for the sake of the mdb importing functions. [update] The 32-bit assembly also needs to be able to call into some of the other 64-bit assemblies. Maybe this is a killer anyway? [/update] Thanks in advance.Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
modified on Friday, August 1, 2008 11:35 AM
-
I am developing a major application that (among other things) talks to SQL Server databases. I have it built with a platform target of "Any CPU". However, it has to be able to import legacy data from mdb databases. The Jet database engine is only available on the 32-bit platform. I have created a .NET assembly built with a platform target of "x86" for the main application to call to do the importing. The problem is that I get a
BadImageFormatException (0x8007000b)
when trying to load the dll when running 64-bit Vista. There seems to be a division of opinion about whether the 64-bit framework should be able to load 32-bit dlls. Does anyone have a definitive answer, or a solution to the problem? I really don't want to have to build the whole app to target 32-bit just for the sake of the mdb importing functions. [update] The 32-bit assembly also needs to be able to call into some of the other 64-bit assemblies. Maybe this is a killer anyway? [/update] Thanks in advance.Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
modified on Friday, August 1, 2008 11:35 AM
On a 64-bit x64 machine: anycpu.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll x64.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll Ref:- http://blogs.msdn.com/joshwil/archive/2005/04/08/406567.aspx[^]
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
-
On a 64-bit x64 machine: anycpu.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll x64.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll Ref:- http://blogs.msdn.com/joshwil/archive/2005/04/08/406567.aspx[^]
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
Thanks for the link. I've seen another blogger contradict that but I think my experience shows that the guy you link to is the one who's right. I suppose I'll just have to drag everything down to x86 :( . Maybe one day I'll write a separate app to do the conversion.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
-
Thanks for the link. I've seen another blogger contradict that but I think my experience shows that the guy you link to is the one who's right. I suppose I'll just have to drag everything down to x86 :( . Maybe one day I'll write a separate app to do the conversion.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
In one of my project's , I remember we had two saperate build one for 64-bit & one for 32-bit machine < although i dont like it > We had to get/beg all 3-rd party dll to be 64-bit.
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM