[英]Can't connect to Oracle database in Visual Studio 2019 C#
I'm trying to connect to oracle database but I get this error我正在尝试连接到 oracle 数据库,但出现此错误
System.BadImageFormatException: 'Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies.
System.BadImageFormatException:'无法加载文件或程序集'Oracle.DataAccess,Version=2.112.1.0,Culture=neutral,PublicKeyToken=89b483f429c47342'或其依赖项之一。 An attempt was made to load a program with an incorrect format.'
试图加载格式不正确的程序。
Code:代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
string ordb = "Data Source =orcl ;User Id = hr ; password =hr;";
OracleConnection conn;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new OracleConnection(ordb);
conn.Open();
}
}
}
Check your dll references, your app seems to be an X64 base, but maybe one of the dll's is of a different format检查您的 dll 引用,您的应用似乎是 X64 基础,但可能其中一个 dll 的格式不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.