2009-08-09 59 views
16

我正在使用Visual Studio 2008速成版,並且正在嘗試使用Oracle.DataClient開發小型應用程序。 嘗試連接到目標系統中的數據庫時,出現上述錯誤。當使用Oracle.DataClient時,提供程序與Oracle客戶端錯誤版本不兼容。使用Oracle.DataClient

我已經添加了對Oracle 10gR2的Oracle ODP.net提供程序的引用,並且在目標機器上安裝了Oracle 10gR2數據庫的副本。儘管如此,我收到了錯誤。 在發佈之前,我在SO處閱讀this post,並且我安裝了即時客戶端,錯誤仍然存​​在。 下面是完整的錯誤堆棧。

************** Exception Text ************** 
System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() 
    at Oracle.DataAccess.Client.OracleConnection..cctor() 
    --- End of inner exception stack trace --- 
    at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString) 
    at Employees1.frmLogin.oralogin() 
    at Employees1.frmLogin.btnTest_Click(Object sender, EventArgs e) 
    at System.Windows.Forms.Control.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
    at System.Windows.Forms.Control.WndProc(Message& m) 
    at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
    at System.Windows.Forms.Button.WndProc(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.42 (RTM.050727-4200) 
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll 
---------------------------------------- 
API Data Conversion Assistant 
    Assembly Version: 0.0.0.1 
    Win32 Version: 0.0.0.1 
    CodeBase: file:///C:/Documents%20and%20Settings/3i/My%20Documents/My%20Dropbox/Sathya's%20dropbox/VisualStudio%20Releases/APIDataconversion/Application%20Files/API%20Data%20Conversion%20Assistant_0_0_0_3/API%20Data%20Conversion%20Assistant.exe 
---------------------------------------- 
System.Windows.Forms 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.42 (RTM.050727-4200) 
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll 
---------------------------------------- 
System 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.42 (RTM.050727-4200) 
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll 
---------------------------------------- 
System.Drawing 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.42 (RTM.050727-4200) 
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll 
---------------------------------------- 
Oracle.DataAccess 
    Assembly Version: 2.102.2.20 
    Win32 Version: 2.102.2.20 

我有我開發的應用程序的計算機上安裝了Oracle 11g中,它工作正常存在,但在目標機器上,我得到這個錯誤。 任何輸入將不勝感激。

PS:如上所述,引用的Oracle.DataClient.dll文件版本對應於10gR2,而不是11g。

+3

(從 'ociw32.dll.dbl' 重命名)這將是如果回答問題的人會在評論中提供他們的理由,那麼這很不錯... – DCookie 2009-08-10 16:15:23

+1

我認爲這是一個很好的問題,因爲我整個上午都在同一個問題上掙扎。 – Chris 2009-08-11 03:15:32

回答

17

我一直在尋找這個問題進一步,你只需從ODP.Net同一下載版本抓住所有適當的DLL的,並把它們放在同一文件夾中的EXE文件,因爲ODP.Net對於不混合版本號很煩惱,這就是你看到的問題(無論是或者oci.dll完全沒有,在這種情況下,它煩惱地給出相同的錯誤)。

我已經解釋瞭如何在這裏做到這一點:http://splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c 下面是它雖然要點:

+0

非常感謝您的指導,它像一個魅力!對於具有相同問題的其他人:[最新版本](http://download.oracle.com/otn/nt/instantclient/112020/instantclient-basic-nt-11.2.0.2.0.zip)直接包含DLL 。 – 2011-12-16 11:26:09

1

您是否使用客戶端系統上的ODBC管理員創建併成功測試了連接?

在9i和10g客戶端中存在導致此錯誤的權限問題的修補程序。如果你在10.2.0.1,你可能需要升級到10.2.0.3來解決這個問題。

+0

@dcookie:是的,ODBC連接成功,因爲我的SP將數據從MS SQL Server檢索到Oracle表中。 – Sathya 2009-08-10 19:08:43

0

嗯,我已經讓我的應用程序使用Ole DB(System.Data.Oledb命名空間)連接,它工作正常。考慮到該應用只是調用Oracle SP的前端,並且沒有返回任何值,我想這種方法是可以接受的,因爲在2天內我試圖解決這個問題,我可以完成很多更多的應用程序開發。 我仍然樂於接受答案,因爲我可以從將來承擔任何此類應用程序的錯誤中學習。

0

我遇到了同樣的問題。如果您的計算機上安裝了11g客戶端,那麼您需要使用11g ODP.Net DLL。我必須完全卸載所有內容,然後安裝11g客戶端,然後安裝11g ODP.NET驅動程序。這些驅動程序會安裝在GAC中,它會變得很痛苦。

*請注意,這是從我的DBA我的理解是,如果你這僅適用於沒有連接到任何版本低於9i的*

我們不得不這樣做我們的服務器上也。

HTH

相關問題