I have an assembly, Utils which is set to build as "Any CPU", and I have a managed EXE which is set to also build as "Any CPU". The exe uses my Utils assembly.
My Utils assembly MUST load a unmanaged, non-com 32bit DLL and call some functions.
I am getting an exception "An attempt was made to load a program with an incorrect format. " every time.
Is there any way to still have my EXE and assembly running in 64bit mode but still load the 32bit DLL to make some simple function calls?
I know that if I build my EXE in 32bit mode then it will work, but my Utils assembly is going to be used by a WCF web service and other programs that might run in 64bit mode and it still needs to call the 32bit dll.
Is there any way? I've tried using LoadLibrary, which just returns a 0 pointer when called from 64bit code, and DllImport which gives me an exception.
Thank you for your help.