How to correctly load 32-bit DLL dependencies when running a program from a batch file

Posted by neilwhitaker1 on Stack Overflow See other posts from Stack Overflow or by neilwhitaker1
Published on 2010-05-11T17:00:56Z Indexed on 2010/05/11 17:04 UTC
Read the original article Hit count: 203

I have written a tool that references Microsoft.TeamFoundation.VersionControl.Client.dll, which is a 32-bit DLL.

When I build my tool on 64-bit Windows, I set Visual Studio to specifically target X86 in order to force it to a 32-bit build.

Targetting X86 instead of All-CPU's prevents me from getting a BadImageFormatException, as long as I invoke the tool directly (e.g. by typing "myTool.exe" on the command line). However, if I run a batch file that invokes the tool, I still get the exception. This happens even if the batch file runs in a 32-bit command prompt (%WINDIR%\SysWOW64\cmd.exe).

What else can I do to make this work?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about assembly-resolution