How to correctly load 32-bit DLL dependencies when running a program from a batch file
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 开发者_如何学JAVAbuild.
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?
Since it is a 64-bit machine you are running the command line on, it is in 64-bit. Here is how you open and run a 32-bit command line:
http://www.tipandtrick.net/2008/how-to-open-and-run-32-bit-command-prompt-in-64-bit-x64-windows/
I would check these too:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic46570.aspx and http://filips.net/archives/2008/01/17/getting-badimageformatexception-in-64-bit-windows/
精彩评论