【问题标题】:Running in 64 bit mode with the 32 bit Oracle Service使用 32 位 Oracle 服务在 64 位模式下运行
【发布时间】:2018-06-05 18:31:52
【问题描述】:

这个问题类似于link

link2

我修复了这个问题,但是当我打开新项目 Wcf 服务库时,我遇到了同样的问题,而且我之前所做的所有这些更改都没有帮助我。

我尝试了以前做过的所有事情,甚至更多,但没有帮助。

重要要说,如果我在另一个项目中做同样的事情,一切正常,但在 WcfServiceLibrary 中它不起作用。在 WcfServiceApplication 中它也起作用。

我用的是VS2012(4.5) Win7(64),我的Oracle clien 32,但是在其他项目中这不是问题。

也许是因为我不知道 Wcf 库项目。 我只是建立从数据库中保存 datd 的服务,但在连接到 db 时出现错误。

Error: 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.

我的代码

using (OracleConnection con = new OracleConnection())
{
    con.ConnectionString = "User Id=zxc;Password=zxc;Data Source=NXE";
    con.Open();//here i get error
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = con;
    cmd.CommandText = "select * from " + Table;
    int rowsUpdated = cmd.ExecuteNonQuery();
    OracleDataReader reader = cmd.ExecuteReader();
    String DataFromORL = "";
    int row = 0;
    while (reader.Read() && row < 50)
    {
        row++;
        if (reader.HasRows)
        {
            DataFromORL += reader.GetInt32(0);
        }
    }
}

【问题讨论】:

  • con.Open() 行的错误是什么?
  • 尝试加载 Oracle 客户端库会引发 BadImageFormatException。在安装了 32 位 Oracle 客户端组件的 64 位模式下运行时会出现此问题。
  • 将构建平台目标从“任何 CPU”更改为仅 32 位,看看是否没有帮助
  • 不,它没有帮助,

标签: c# asp.net oracle


【解决方案1】:

我也遇到了同样的问题。 对我来说,通过执行以下操作解决了问题。 在此之前检查您是否安装了 32 位和 64 位 Oracle 客户端以使其在两种环境中都可用。

对于我来说,出现此错误的原因。

错误:尝试加载 Oracle 客户端库引发 BadImageFormatException。在安装了 32 位 Oracle 客户端组件的 64 位模式下运行时会出现此问题。

是因为环境变量只有一个安装位置,而且是32位安装位置,这就是错误的原因在安装了32位Oracle客户端组件的64位模式下运行时会出现此问题。

所以,为了解决这个问题,我还添加了 64 位安装位置并重新启动了我的 Visual Studio。如果它也不起作用,请尝试重新启动系统,我们应该在安装 Oracle 客户端时指定的 Oracle 客户端安装位置中添加两个可用的 bin 目录。

在我的系统位置是这样的:

32-bit C:\app\client\&lt;user&gt;\product\12.1.0\client_2\bin
64-bit C:\app\client\&lt;user&gt;\product\12.1.0\client_1\bin

【讨论】:

    猜你喜欢
    • 2014-05-16
    • 2013-05-08
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    • 2011-05-13
    相关资源
    最近更新 更多