How do I reference a 32 bit DLL in a 64 bit project?

Viewed 10583

I've got a C# 2.0 project which is set to target 'Any Cpu', however it is referencing a C++ project that's building a 32 bit dll.

When I try to run my program on a 64bit machine I get the following error:

System.BadImageFormatException was unhandled Message: Could not load file or assembly TreeTMHook, Version=1.0.2889.19619, Culture=neutral, PublicKeyToken=null or one of its dependencies. An attempt was made to load a program with an incorrect format.

How can I fix this?

Update

I want to be able to keep the main project as any cpu.

Thanks.

5 Answers

Please use .net reflection and consume objects and its methods. Instead of direct 32 bit dll reference.

Related