发布同时支持 64 位和 32 位的 Web 二进制文件吗?网络平台

发布于 2024-08-23 10:23:07 字数 268 浏览 2 评论 0原文

我想发布同时支持 32 位和 64 位的应用程序。我正在使用 elmah 和 SQLite。这两个软件包都有单独的 32 和 64 位二进制文​​件。我无法同时添加 32 位和 64 位 DLL。我尝试同时添加 32 和 32我的 bin/release 文件夹中的 64 位 DLL 具有不同的文件名,并且我收到错误的图像格式错误。 (我通过在目录中包含 DLL 的 Windows 服务器 64 位和我的 32 位系统上运行进行测试)。

如何发布应用程序以便同一文件夹可以以 32 位或 64 位运行?

I would like to release my app with both 32 and 64bit support. I am using elmah and SQLite. Both packages have a separate binary for 32 and 64bits. I cant add both 32 and 64bit DLL. I tried adding both 32 & 64 bit DLLs with a different filename in my bin/release folder and i get an bad image format error. (I tested by running on a Windows server 64 bit with both DLLs in the directory and on my system which does 32bit).

How do i release the app so the same folder can be run as either 32bits or 64bits?

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

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

发布评论

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

评论(1

看春风乍起 2024-08-30 10:23:07

不久前刚刚与 32 位和 64 位进行了较量,我将对此进行尝试,至少有一些一般性的观察。我知道这个问题已经有一年多了,但我希望答案无论如何都能帮助别人,无论你是否“接受”这个答案(与某些人相反,这不是我在 StackOverflow 上回答问题的原因)。

首先,在您的情况下,仅 32 位可以在 WOW64 环境中工作吗?通常会的,这可以简化您的情况。

然而,在某些情况下,第三方库会使 WOW64 无法运行,至少根据他们的文档,这就是我面临的情况。为了解决这个问题,我必须同时拥有 32 位和 64 位版本。如果有办法以某种方式将它们都释放到“同一文件夹”中,我没有找到。不过,这样做确实并不太难。我确实必须手动编辑 Visual Studio 项目文件。如果我记得的话,基本步骤是:

  1. 在 Visual Studio 中仔细设置构建定义,以便发布版本和调试版本都正确设置各个项目。就我而言,这意味着与本机库交互的任何内容都必须以 x86 或 x64 格式构建,而不是任何 CPU。据我所知,仅限 MSIL 的项目可以是任何 CPU。
  2. 编辑项目文件(例如.csproj),以便根据构建将正确的第三方 DLL 放入正确的文件夹中。如果有更简单的方法来完成此任务,我没有看到。您的解决方案中可能有一个明显的项目文件会导致这种情况发生,尽管它确实可能发生在解决方案中的任何位置,只要:
  3. 在您的实际 Web 项目中,确保将带有第三方 DLL 副本的项目添加为参考,即使 Web 项目不直接使用其他项目。这样,文件将被复制到您的构建目录。对我来说,这似乎是 MSBuild 或 Visual Studio 中的一个错误,但从 VS2010 开始,它似乎尚未修复。此外,如果您需要将第三方 DLL 复制到 App_Code 等目录,则可能需要编辑 Web 项目文件才能完成此操作。

我必须在工作中查看项目文件并查看我具体做了哪些更改,但这些是基本步骤。除非您可以将整个项目编译为 Any CPU,否则我认为您将需要编译 32 位和 64 位版本并部署您需要的版本。您的实际代码可能不会改变,除非您使用本机或非托管代码。

可能有人比我更了解这一点,但我希望这对某人有帮助。我会尽力回答评论中留下的任何问题。

Having just fought with 32- vs. 64-bit not long ago, I'll take a shot at this, at least with some general observations. I know this question is over a year old, but I hope the answer helps someone anyway, regardless of whether you "accept" the answer (which, in contrast to some, is not why I answer questions on StackOverflow).

First off, will 32-bit-only work in a WOW64 context in your situation? Often it will, and that can simplify your situation.

There are, however, situations in which third-party libraries make WOW64 not workable, at least according to their documentation, which is the situation I was facing. To solve the problem, I had to have both a 32-bit and a 64-bit build. If there is a way to release them both in the "same folders" somehow, I did not find it. However, it really was not too difficult to do so. I did have to edit the Visual Studio project files by hand. If I recall, the basic steps were:

  1. Set up my build definitions in Visual Studio carefully, so that both release and debug versions had individual projects set correctly. That meant, in my case, that anything interacting with the native libraries at all had to be built in either x86 or x64 format, not Any CPU. Projects that are MSIL-only can be Any CPU, as far as I can tell.
  2. Edit your project files (e.g., .csproj) so that the correct third-party DLLs are put in the correct folders based on the build. If there was an easier way to accomplish this, I didn't see it. There may be an obvious project file within your solution for this to happen, though it can really happen anywhere in your solution, so long as:
  3. In your actual web project, make sure you add the project with the third-party DLL copy as a reference, even if the web project does not use this other project directly. That way, the files will get copied to your build directory. This seems like a bug in either MSBuild or Visual Studio to me, but as of VS2010, it does not seem to have been fixed. Also, if you need to copy the third-party DLLs to a directory such as App_Code, you may need to edit the web project file to accomplish that.

I would have to be at work to look at the project files and see what changes I specifically made, but these were the basic steps. Unless you can get away with your entire project being compiled as Any CPU, I think you will need to compile both a 32-bit and 64-bit version and deploy the one you need. Your actual code likely will not change, unless you are using native or unmanaged code.

Someone may come along who knows more about this than I, but I hope this helps someone. I'll try to answer any questions left in the comments.

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