An attempt was made to load a program with an incorrect format

Could not load file or assembly 'NameOfAssemblyGoesHere' or one of its dependencies. An attempt was made to load a program with an incorrect format.

This message being spewed-forth by an application means that the DLL concerned has been compiled as a specific "bitness", but one that doesn't match that which IIS is running at. The most usual reason for this is an assembly marked as "x86" deployed to an "x64" server. If the assembly doesn't P/Invoke out to any 32-bit DLLs, change the platform target to "AnyCpu".

As far as the .net framework is concerned, the x86/x64 categorisation is only used as an indicator of requirements, thus if no P/Invoke is going on it's not needed, as the JIT compiler takes the assembly and JIT compiles it to the relevant instruction set at runtime anyway.

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments

Add a Comment