从批处理文件运行程序时如何正确加载 32 位 DLL 依赖项

发布于 2024-08-31 23:37:20 字数 370 浏览 0 评论 0原文

我编写了一个引用 Microsoft.TeamFoundation.VersionControl.Client.dll 的工具,它是一个 32 位 DLL。

当我在 64 位 Windows 上构建工具时,我将 Visual Studio 设置为专门针对 X86,以强制其构建为 32 位。

只要我直接调用该工具(例如,通过在命令行上键入“myTool.exe”),以 X86 而不是全 CPU 为目标就可以防止出现 BadImageFormatException。。但是,如果我运行调用该工具的批处理文件,我仍然会遇到异常。即使批处理文件在 32 位命令提示符 (%WINDIR%\SysWOW64\cmd.exe) 中运行,也会发生这种情况。

我还能做些什么来完成这项工作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文