locked
64-bit Build error RRS feed

  • Question


  • Hi All,

    I am trying to build a solution on 64-bit which was developed on 32-bit.
    During the biuld it throwing an error.

    an attempt was made to load an assembly with an incorrect format .dll

    Thanks for you suggestions
    Murari

    Tuesday, January 26, 2010 3:06 PM

All replies

  • That error message suggests that one of the assemblies is referencing a component that was built targetting x86.  If you run an x64 application (64bit), every assembly used must be targetting either AnyCPU or x64.  Any native code (ie: a wrapped COM object, or a DLL invoked via P/Invoke) must also be compiled as a 64bit DLL.

    One of the DLLs in your project, or referenced by your project, is still targetting x86.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 4:47 PM
  • THanks for the Suggestion.

    But when I try to build the referend project dll to x64.It still throwing the same error.

    an attempt was made to load an assembly with an incorrect format .dll

    Please suggest how to resolve this

    Thanks
    Murari
    Tuesday, January 26, 2010 5:43 PM
  • Look in the output window - it should tell you which assembly can't be loaded, right before it prints that error message.

    By looking at that, you should be able to figure out what is trying to pull in a 32bit DLL.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 5:49 PM
  • Thanks for  valuable suggestion.


    I tried removing the dll manully and tried build the ref project.
    But the interesting thing is dll was created again and failed with same error 

    Thanks
     Murari
    Tuesday, January 26, 2010 5:57 PM
  • THe "referenced project" is probably referencing the DLL that's causing the error.  You'll need to change it's reference to a 64bit version of that DLL.

    It's not just the projects in your solution - you have to make sure EVERY DLL referenced by any of your projects are either AnyCPU or x64 to compile and run 64bit code.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 6:09 PM
  • Thanks for your time,

    At solution level I am setting Build properties
    Configuration : Release
    Platform : x64.

    Then Visual studio should take care automatically. such that all the dll's of that solution will x64 compatible.

    Is their is simple way to convert only one dll to x64,Since only for one dll I facing this issue.
    I really appreciate your help

    Thanks
    Murari

    Tuesday, January 26, 2010 6:22 PM
  • Check the project properties for that specific project.  You can't just set this at the solution level, since that doesn't (necessarily) map to project settings.

    Right click on the project for that DLL, and fix the settings for it (when you have the solution set to x64).  That DLL project may still be compiling to x86.

    You can also check the configuration manager for the solution (right click on solution, choose "Configuration Manager") - make sure that the project in question is choosing the correct option when x64 is chosen for the solution settings.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 6:32 PM
  • Thanks for you suggestion,

    I have checked  all the properties everything seems to be correct,As you doubt it still compiling to x86.

    Where should look for it to change the project compilation x64.


    thanks a lot
    Murari
    Tuesday, January 26, 2010 6:38 PM
  • It depends on the project's language.

    RIght click on the project, and choose proeprties.

    If it's C#, it'll be "Platform Target" on the main screen.

    If it's C++, make sure the configuration in the configuration manager is set to x64.

    For VB.NET, in the project settings, under Compile, choose "Advanced Compile Options..." - Choose Target CPU - x64.


    ALso, realize, it's not just the project settings.  If you're using platform invoke to call into a native DLL, that native DLL needs to be 64bit. Also, any references by your library need to be 64bit, too.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 6:47 PM
  • Thanks reed for your valuable suggestion,



    I have found some the reference are pointing to below path.
    E:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\

    When I check E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
    thier is no PublicAssemblies folder.

    Does that mean I haven't installed Visual studio properly on 64-bit machine.

    Please can you throw some light on the issue.

    Thanks
    Murari
    Tuesday, January 26, 2010 7:07 PM
  • They're pointing to "Program Files (x86)" -

    You probably just need to remove those references, and re-add them.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 7:13 PM
  • Hi Reed,

    Since their is no publicAssemblies folder in E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
    So no referenced dll's are present , In this scenario what should I do

    Please help me

    Thanks a lot
    Murari
    Tuesday, January 26, 2010 8:18 PM
  • Remove the references in the project, and add them using the Add Reference tool.  It should handle putting the appropriate paths in place.


    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, January 26, 2010 8:39 PM
  • Hi Reed,

    I try to add the refernce again, but only required dll's are present in x86.
    As I have pointed earlier, Does that mean I haven't installed Visual studio properly on 64-bit machine.

    Thanks
    Murari 
    Wednesday, January 27, 2010 7:35 AM
  • What DLLs are they?

    It may be that the libraries you're trying to use only work in x86 - and targetting x64 may not be possible.  There are quite a few libraries that only have 32bit versions....
    Reed Copsey, Jr. - http://reedcopsey.com
    Wednesday, January 27, 2010 4:30 PM
  • Hi Reed,

    I am looking for following dll's
    Microsoft.XLANGs.BizTalk.Engine
    Microsoft.XLANGs.BaseTypes
    Microsoft.XLANG.Engine

    Thanks
    Murari
    Wednesday, January 27, 2010 5:15 PM
  • Which version of Biztalk are you using?

    Biztalk 2006 Standard Edition is 32bit only.

    64 bit execution is available on some platforms.  You may need to reinstall Biztalk if you're using a platform that allows native 64bit execution, in order to get the appropriate, x64 assemblies.

    That being said, this is the issue - if you can get those assemblies in place, it will work.  If not, you'll need to just target x86, and run under WOW64.
    Reed Copsey, Jr. - http://reedcopsey.com
    Wednesday, January 27, 2010 5:28 PM
  • Hi Reed,


    I am using BizTalk 2009,so please can you detailed me the steps.

    Thanks
    Murari
    Thursday, January 28, 2010 8:51 AM
  • I recommend asking on the BizTalk Server Forums.  I am not familiar with BizTalk myself - so you'll have to either look at the links, or ask there...


    Reed Copsey, Jr. - http://reedcopsey.com
    Thursday, January 28, 2010 4:41 PM