如何强制.NET应用程序在32位模式下运行 [英] How to force .NET application to run in 32bit mode

查看:1556
本文介绍了如何强制.NET应用程序在32位模式下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行在Win7的X64我的.net 3.5 WinForms应用程序。该应用程序使用的NHibernate和System.Data.OracleClient的访问Oracle数据库。 Oracle客户端是32位。

I am trying to run my .NET 3.5 WinForms application on a Win7 x64. The application uses NHibernate and the System.Data.OracleClient to access an Oracle database. The Oracle client is 32bit.

在启动应用程序,我得到了以下错误消息

When starting up the app I get the following error message

尝试加载Oracle客户端库扔BadImageFormatException。    在64位模式安装了32位Oracle客户端组件运行时,会出现此问题。

Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.

在回应,我针对性我生成到x86平台:

In response to that, I targetted my build to the x86 platform:

要我吃惊的是,非常相同的错误消息出现当试图执行一个新的版本Win7的平台。

To my surprise, the very same error message appeared when trying to execute that new build on the Win7 platform.

NHibernate的组件在运行时装载了的Assembly.Load(...);

The NHibernate assembly is loaded at runtime by Assembly.Load("...");.

难道说NHibernate的DLL仍然运行在64位模式,而主机exe文件在32位模式下运行。这听起来很奇怪,我。或者会不会是出于什么原因,在64位模式我的应用程序运行,即使它是针对86?

Could it be that the NHibernate DLL still runs in 64 bit mode whilst the host exe runs in 32 bit mode. That sounds strange to me. Or could it be that for whatever reason, my application runs in 64 bit mode even though it was targeted to x86?

更新:

我检查了使用CorFlags我的二进制文件,它标志着32位:

I checked my binary using CorFlags, and it is marked 32 bit:

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 3
ILONLY    : 1
32BIT     : 1
Signed    : 0

我还检查了它在任务管理器,它有一个 * 32 后缀。

我也试过和使用CorFlags到32位标志添加到的所有来与我的应用程序组件。它仍然会产生相同的错误消息。

I also tried and used CorFlags to add the 32bit flag to all assemblies that come with my application. It still yields the same error message.

我疑惑不解... ...不解...

I'm puzzled... puzzled... puzzled...

推荐答案

32位进程无法加载64位的DLL,反之亦然(见<一href="http://helgeklein.com/blog/2008/04/windows-x64-all-the-same-yet-very-different-part-6/">this了解详细信息)。这意味着,如果你的程序成功加载64位的DLL那么它最绝的是一个64位进程。您可以验证在任务管理器(如拉塞建议),或者通过描述的其他方式的此处。该文章还具有.Net的Windows x64上的更多信息。

32-bit processes cannot load 64-bit DLLs and vice versa (see this for details). That means that if your process successfully loaded a 64-bit DLL then it most definitely is a 64-bit process. You can verify that in Task Manager (as Lasse suggested) or via other means described here. That article also has more information on .Net on Windows x64.

这篇关于如何强制.NET应用程序在32位模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆