具有许多强制 32 位程序集的应用程序

发布于 2024-09-06 11:00:04 字数 179 浏览 3 评论 0原文

我有一个包含许多程序集和第三方实用程序的 VS 解决方案。我需要在 64 位计算机上运行时强制应用程序运行 32 位。该应用程序在 32 位计算机上运行良好。我强制 .exe 文件仅需要 32 位,当在 64 位计算机上运行时,我收到“尝试加载格式不正确的程序”错误。据我了解,更改 exe 会强制所有程序集作为 32 位加载。到底是怎么回事?

I have a VS solution with many assemblies and third-party utilities. I need to force the app to run 32-bit when running on a 64-bit machine. The app runs just fine on a 32-bit machine. I forced the .exe file to be only 32-bit required and when run on the 64-bit machine, I am getting "an attempt was made to load a program with an incorrect format" error. It was my understanding that changing the exe would force all the assemblies to load as 32-bit. What is going on?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻梦旅人 2024-09-13 11:00:04

我知道这是一个老问题;也许你已经找到了答案。

我不熟悉设置 ILONLY 和 32BITREQUIRED...通常在编译之前在编译器下拉框中选择 x86 而不是 ANYCPU 来处理您需要的一切。您还可以在配置管理器中验证所有应用程序是否都设置为编译为 x86。

最有可能的是,您遇到的情况是您的第三方实用程序之一在 64 位计算机上安装了 64 位 DLL,并且您的强制 32 位应用程序正在尝试加载 64 位 DLL。如果第三方 DLL 有 32 位和 64 位版本,安装程序很可能足够聪明,知道要安装哪一个。

在64位机器上你可以去两个地方检查:

  1. 如果程序安装到C:\Program Files\,那么它是一个64位DLL;否则它会被安装到 C:\Program Files (x86)\
  2. 从命令行导航到 GAC:c:\Windows\ assembly 并在 GAC_32 与 GAC_64 下查看。如果您在 GAC_64 下找到它,则您正在尝试加载 64 位 DLL

HTH!
詹姆斯

I know this is an old question; maybe you already found your answer.

I'm not familiar with setting ILONLY and 32BITREQUIRED... usually choosing x86 instead of ANYCPU in the compiler drop-down box before compiling takes care of everything you need. You can verify that all your apps are set to compile to x86 in the configuration manager, as well.

Most likely, what you're running into is that one of your third-party utilities installed a 64-bit DLL on the 64-bit machine, and your forced-32-bit application is trying to load a 64-bit DLL. If a third-party DLL has a 32-bit and 64-bit version, chances are the installer is smart enough to know which one to lay down.

Two places you can go on the 64-bit machine to check:

  1. If the program installed to C:\Program Files\, it's a 64-bit DLL; otherwise it would have been installed to C:\Program Files (x86)\
  2. Navigate to the GAC from the command line: c:\Windows\assembly and look under GAC_32 vs. GAC_64. If you find it under GAC_64, you're trying to load the 64-bit DLL

HTH!
James

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文