我運行:錯誤加載DLL文件在Windows 10 C#ODP.NET
- 的Windows 10家
- Oracle數據庫11g企業版11.2.0.1 - 64位版本
- Visual Studio速成2013
我想編寫一個簡單的C#應用程序從Oracle數據庫中讀取數據,並希望使用ODP.NET。但是,運行該程序時,我得到一個立即運行時錯誤。
我開始了一個新的Windows Forms項目。
我聯繫服務Oracle.DataAccess.dll在目錄C:\程序\戴夫\產品\ 11.2.0 \ dbhome_1 \ ODP.NET \ BIN \ 2.X \
我的代碼:
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testapp_2
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
代碼:
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace testapp_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
OracleConnection conn = new OracleConnection();
}
}
}
的錯誤是:
無法加載文件或程序集'Oracle.DataAccess,版本= 2.112.1.0, Culture = neutral,PublicKeyToken = 89b483f429c47342'或其一個 依賴關係。試圖加載格式不正確的程序。
在調試模式下運行時,程序暫停在行:
Application.Run(new Form1());
我已經在過去使用Visual STDIO快遞2008和Oracle 10g在Windows XP下使用這種成功,認爲這將是非常就像以前一樣簡單,但顯然不是。
有沒有其他人遇到這個錯誤,並希望找到它一個解決方法嗎?我會非常感謝任何幫助或信息。
非常感謝!
-Dave。
您需要明確地構建x86或x64。同時檢查ODP.NET的製作平臺。 –
驗證您的應用程序的體系結構(32位或64位)與您的Oracle客戶機相同, ODP.NET程序集。 –
檢查答案:http://stackoverflow.com/questions/659341/the-provider-is-not-compatible-with-the-version-of-oracle-client#25412992 –