【问题标题】:Can't connect to Oracle database in Visual Studio 2019 C#无法在 Visual Studio 2019 C# 中连接到 Oracle 数据库
【发布时间】:2020-07-16 23:25:13
【问题描述】:

我正在尝试连接到 oracle 数据库,但出现此错误

System.BadImageFormatException:'无法加载文件或程序集'Oracle.DataAccess,版本=2.112.1.0,Culture=neutral,PublicKeyToken=89b483f429c47342'或其依赖项之一。试图加载格式不正确的程序。'

代码:

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();
        }
    }
}

【问题讨论】:

    标签: c# sql .net database oracle


    【解决方案1】:

    检查您的 dll 引用,您的应用似乎是基于 X64 的,但可能其中一个 dll 的格式不同

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-06
      • 1970-01-01
      • 2013-04-14
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多