Today I was trying to wrap one of our .dll projects in a wcf endpoint and ran into an odd issue that took 3 hours to resolve and the mad skills of my co-worker James to help resolve.
Long story short, when I would F5 my web project which was hosting our WCF endpoints I would get the following message in the browser.
Of course when I got this I immediately jumped to the referencing project and made sure I had referenced all the needed child assemblies. When this checked out I then jumped to the BIN folder to make sure they were copied correctly, they were. When THIS failed I fired up Just Decompile to ensure that the version of the assemblies were right… All of this lead me NO WHERE.
Now that I have done the typical checks I resorted to firing up the Fusion Log viewer with hopes that this would help… Yea that did nothing….
At this point I was beating my head against the desk, this was also the point that I enlisted the skills and knowledge of James. As we were talking through the problem and looking around we made our way over to the project properties of the dll I was referencing. When looking over the properties James noticed that my target platform was x86 (seen below),
which immediately sent up the red flag for him (it did nothing for me). Of course the question of ‘why is this x86’ was asked to which I answered ‘I don’t know’ but I did know the that project was originally a console app project prior to being switched to a library project…. Ding, Ding, Ding…. Console apps are set to x86 by default not Any CPU.
Once we changed it to Any CPU and recompiled my issues were resolved (seen below)
The moral of the story is that if you get the ‘bad image’ error make sure you are not trying to reference an x86 assembly in your x64 projects.
Till next time,
04-25-2012 10:23 AM