无法加载文件或程序集'Oracle.DataAccess,Version = 4.112.4.0,Culture = neutral,PublicKeyToken = 89b483f429c47342' [英] Could not load file or assembly 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342'

查看:135
本文介绍了无法加载文件或程序集'Oracle.DataAccess,Version = 4.112.4.0,Culture = neutral,PublicKeyToken = 89b483f429c47342'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在服务器中安装了Oracle 11 g r 2 ,并下载了 ODAC112040Xcopy_64bit 并安装了.net组件.

I have installed oracle 11 g r 2 in the server, and I downloaded ODAC112040Xcopy_64bit and installed the .net components.

我将此位置 Oracle_Folder \ odp.net \ bin \ 4 中存在的 Oracle.DataAccess.dll 复制到其中的 bin 文件夹中我的Visual Studio项目

I copied Oracle.DataAccess.dll that exists in this location Oracle_Folder\odp.net\bin\4 to the bin folder inside my Visual Studio project

执行代码时,出现此异常:

When I executed my code, I got this exception:

TestOracleConnection.exe中发生了'System.BadImageFormatException'类型的未处理异常

An unhandled exception of type 'System.BadImageFormatException' occurred in TestOracleConnection.exe

其他信息:无法加载文件或程序集"Oracle.DataAccess,版本= 4.112.4.0,区域性=中性,PublicKeyToken = 89b483f429c47342"或其依赖项之一.试图加载格式错误的程序.

Additional information: Could not load file or assembly 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.

我的代码是:

public string CallCardDetails(string CallCardNo)
{
    //initialize
    using (DataSet ds = new DataSet())
    {
        //connect
        using (OracleConnection conn = new OracleConnection("User Id=oraDB;Password=ora;Data Source=CCT"))
        {
            // Oracle uses : for parameters, not @
            string query = "SELECT idcard from CallCardTable where idcard= :pCallCardNo";

            // Let the using block dispose of your OracleCommand
            using (OracleCommand cmd = new OracleCommand(query, conn))
            {
                // Note: be careful with AddWithValue: if there's a mismatch between the .NET datatype of
                // CallCardNo and the idcard column you could have an issue.  Cast the value you provide
                // here to whatever is closest to your database type (String for VARCHAR2, DateTime for DATE, Decimal for NUMBER, etc.)
                cmd.Parameters.Add(":pCallCardNo", CallCardNo);
                conn.Open();

                // Again, wrap disposables in a using or use try/catch/finally (using will dispose of things in case of exceptions too)
                using (OracleDataAdapter dA = new OracleDataAdapter(cmd))
                {
                    dA.Fill(ds);

                    return ds.GetXml();
                }
            }
        }
    }
}

推荐答案

好的,根据我对ODP.NET的经验,我将提出以下建议:

Okay, I'm going to suggest the following based on my experience with ODP.NET:

您的系统正在尝试加载64位Oracle DLL,但不能,因为该应用程序以32位模式运行.尝试将您的应用程序设置为显式为64位.或者,安装32位ODP.Net驱动程序,看看它们是否更好.

Your system is attempting to load the 64 bit Oracle DLL, and can't because the application is running in 32 bit mode. Try setting your application to explicitly be 64 Bit. Alternatively, install the 32 bit ODP.Net drivers and see if those work any better.

这篇关于无法加载文件或程序集'Oracle.DataAccess,Version = 4.112.4.0,Culture = neutral,PublicKeyToken = 89b483f429c47342'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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