I am using CSLA 22.214.171.124 in my data access layer. I have deployed my application on my laptop and someone's else laptop and the application is working like a dream, but as soon as I deploy it to a terminal server 2008 64bit I get the following error.
Could not load file or assembly 'CSLA 126.96.36.199'....An attempt was made to load a program with an incorrect format
Is this because it is a 64bit machine? And if so is there a CSLA.dll that I can use for a 64bit?
Yes, this is a 32/64 bit issue, but I think it's because your .EXE is mismatched in how it was built compared to your DLLs.
We have had similar issues here, but only because we have a 32 bit C++ DLL that is part of our assembly set. So, we have to be sure that the "Platform target" for the .EXE itself is x86. It's the setting on the entry .EXE that seems to control this.
So, one thing to try to look at the "Build" Properties tab of your .EXE and your DLL's to make sure that everything is consistent. If an EXE is set to "Any CPU" (or "x64") while a DLL is set to x86, then it won't run on an x64 box. Similarly, if the .EXE is set to x86 and the .DLL is x64, you'd also have trouble. (I'm not an expert on this, but we have had this happen several times and managed to correct it by managing the Platform target of the individual .EXE/assembly projects). If everything you are using is .NET managed code and you have no 32 bit dependencies (internal or external), then I'd think everything should be set to "Any CPU".
Thats not true, an assembly that is set to compile as x86 will still run on x64. An assembly compiled as x64 will not run on a 32bit operating system. I would compile the CSLA library as AnyCPU. The easiest place to manage this is in the Configuration manager. Right click the solution in the solution explorer to edit this setting. The only time you should receive a BadImageFormatException is when an x86 compiled assembly attempts to load a x64 compiled assembly.
Thats not true, an assembly that is set to compile as x86 will still run on x64.
I don't think anyone said anything to the contrary.
However, an .EXE compiled to run on "Any CPU" that references a DLL explicitly compiled as x86 will run on an x86 box but will not run on x64 and *must* be compiled as x86.
I build the application with "any cpu" and it is working now.
Thanks for the replies.
Copyright (c) Marimer LLC