Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Calling a 32-bit .NET dll from a 64-bit .NET application [modified]

Calling a 32-bit .NET dll from a 64-bit .NET application [modified]

Scheduled Pinned Locked Moved C#
databasecsharpsql-serversysadminhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil J Pearson
    wrote on last edited by
    #1

    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

    V 1 Reply Last reply
    0
    • P Phil J Pearson

      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

      V Offline
      V Offline
      vikas amin
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • V vikas amin

        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

        P Offline
        P Offline
        Phil J Pearson
        wrote on last edited by
        #3

        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.

        V 1 Reply Last reply
        0
        • P Phil J Pearson

          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.

          V Offline
          V Offline
          vikas amin
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups