gpt4 book ai didi

c# - 无法加载文件或程序集 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342'

转载 作者:行者123 更新时间:2023-11-30 13:56:17 25 4
gpt4 key购买 nike

我在服务器上安装了 oracle 11 g r 2,我下载了 ODAC112040Xcopy_64bit 并安装了 .net 组件。

我把Oracle_Folder\odp.net\bin\4这个位置的Oracle.DataAccess.dll复制到里面的bin文件夹我的 Visual Studio 项目

当我执行我的代码时,我得到了这个异常:

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

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 的经验提出以下建议:

您的系统正在尝试加载 64 位 Oracle DLL,但无法加载,因为应用程序在 32 位模式下运行。尝试将您的应用程序设置为明确为 64 位。或者,安装 32 位 ODP.Net 驱动程序,看看它们是否能更好地工作。

关于c# - 无法加载文件或程序集 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29332898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com