0
OS: Windows 7 64bit
VB: Visual Studio 2010
Oracle Client: 11g

Oracle11gサーバーに接続するアプリケーションを開発しています。Oracle SQL Developer、ODBC(SYSWOW64内)、およびVBServerExplorerを介してOracleサーバーに接続できます。

C:\ Oracle \ product \ 11.2.0 \ client_32 \ ODP.NET \ bin \ 2.x\Oracle.DataAccess.dllにある.NET参照Oracle.DataAccessを使用しています。

他の質問で提案されているように、binフォルダーに.DLLファイルを追加しようとしましたが、機能しません。

他に何か提案はありますか?

アプリケーションを実行すると、次のようになります。 ここに画像の説明を入力してください

詳細は次のとおりです。

System.TypeInitializationException was unhandled
  Message=The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
  Source=Oracle.DataAccess
  TypeName=Oracle.DataAccess.Client.OracleConnection
  StackTrace:
       at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
       at Orc_Test_1.Form1.Button1_Click(Object sender, EventArgs e) in c:\Visual Studio 2010\Projects\Orc_Test_1\Orc_Test_1\Form1.vb:line 9
       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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at Orc_Test_1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: Oracle.DataAccess.Client.OracleException
       DataSource=""
       ErrorCode=-2147467259
       Message=The provider is not compatible with the version of Oracle client
       Number=-11
       Procedure=""
       Source=Oracle Data Provider for .NET
       StackTrace:
            at Oracle.DataAccess.Client.OracleInit.Initialize()
            at Oracle.DataAccess.Client.OracleConnection..cctor()
       InnerException: 

VB.NETコード:

Imports System.Data
Imports Oracle.DataAccess.Client ' ODP.NET Oracle managed provider
Imports Oracle.DataAccess.Types

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim oradb As String = "Data Source=SERVER1;Persist Security Info=True;User ID=username;Password=password;Unicode=True" 'From Server Explorer
        'Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Server1.host.net)(PORT=1522))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Server1))); USER ID = username;Password = password;" 'From TNSnames.ora
        Dim conn As New OracleConnection(oradb)  '<--- Error happens on this line
        conn.Open()
        Dim cmd As New OracleCommand
        cmd.Connection = conn
        cmd.CommandText = "select system_id from schema1.system_impacted where system_name = AWESOME"
        cmd.CommandType = CommandType.Text
        Dim dr As OracleDataReader = cmd.ExecuteReader()
        dr.Read()
        Label1.Text = dr.Item("system_id")
        conn.Dispose()
    End Sub
End Class
4

5 に答える 5

3

私はあなたの痛みを感じます.展開状況で似たようなことを経験しました. おそらく複数のクライアントがインストールされており、環境は古いリリースの dll をプルしています (プロジェクトで最新の oracle.dataaccess.dll が正しく参照されている場合でも)。開発環境でこれを修正することは 1 つのことですが、prod デプロイメント サーバーは別のことです。あなたの展開状況が何であるかはわかりませんが、これが私にとってうまくいったことです。

既存のオラクル ホームで odp.net をアップグレードしようとしたり、新しいオラクル ホームを追加したりするのに苦労した後、すべてを修正する最も簡単な方法は、Oracle からxcopy デプロイメントを使用して最新の odacをダウンロードし、readme に従うことであることがわかりました (ここを参照してください)。これに関する古い記事についても)。基本的には、install.bat ファイルを実行してローカルでセットアップし (別のフォルダーで、私は c:\oracle_odac でした)、プロジェクト参照を変更して、この新しいフォルダーの oracle.dataaccess.dll を指すようにします (私は代わりに 4 を使用しました2.x)、新しいフォルダーの bin ディレクトリをパス (c:\oracle_odac\bin および c:\oracle_odac\odp.net\bin\4) の前に追加します。展開サーバーでは、c:\oracle_odac フォルダー全体を (xcopy などを使用して) コピーし、パスを設定するだけです。

とは言うものの、私は Oracle からのフル マネージド odp.netの製品リリース(現在はベータ版) を心待ちにしています。

編集:アプリまたはWeb構成ファイルでdllpathをセットアップすると、PATHをいじるのを避けることができることを追加するだけです。例えば:

<configuration>
...
    <configSections>
      <section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>  
...

<oracle.dataaccess.client>
    <settings>
      <add name="DllPath" value="c:\oracle_odac\bin"/>
    </settings>
  </oracle.dataaccess.client>
...

これにより、registry や machine.config などの他の設定が上書きされます。また、複数の odp.net 構成が平穏に存在できるようにし、各アプリが同じサーバー上で必要なバージョンを指すようにします。

于 2012-10-22T17:45:27.673 に答える
1

通常、実際には機能しない x32 ドライバーを選択しようとしている x64 アプリケーションを構築しているときに発生します。

この場合にあなたがすること(そしてそれはかなり苦痛です):

  • x32 Oracle クライアントを oraclehome1 にインストールします。
  • x64 Oracle クライアントを oraclehome2 にインストールします。

アプリケーションのビルド (x64、x32) が正しい oraclehome を指していることを確認してください。私はそのコードを手元に持っていませんが、接続文字列などの「Home = oraclehome2」の行に沿ったものだと思います。

于 2012-10-19T15:48:20.083 に答える
1

「コントロール パネル」の「プログラム」セクションで使用可能なすべての Oracle クライアントを削除しました。次に、レジストリで「Oracle」を検索し、Oracle クライアントのすべてのインスタンス/参照を削除しました。3 時間のレジストリの削除と再起動の後、11g クライアントをインストールすると、すべてが期待どおりに機能しました。

注:レジストリで「Oracle」を検索すると、Oracle の VB バージョンへの参照、または「Oracle」の Crytsal Reports ドライバーへの参照がある場合があります。私はこれらを削除しませんでした。そのため、削除するレジストリ項目のファイルの場所や構文に注意してください。

/読む。できます。

于 2012-11-12T15:53:58.617 に答える
0

私の経験では、tbone の提案を試した後、PATH env 変数で遊んだり、他の失敗したプレイをしたりした後、すぐに機能した解決策は、vb.net 実行可能ファイルの同じフォルダーにある下にリストされている 8 つの DLL ファイルのコピーを保存することでした。同じフォルダに Oracle.DataAccess.dll への参照を追加します。

C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug>dir *.dll
 Volume in drive C is OS
 Volume Serial Number is 10EC-8C5D

 Directory of C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug

09/30/2008  07:57 PM           348,160 msvcr71.dll
10/01/2008  02:22 AM           520,192 oci.dll
10/01/2008  01:56 AM           352,256 ociw32.dll
08/12/2009  07:13 AM         1,011,712 Oracle.DataAccess.dll
09/18/2008  08:47 PM         1,130,496 orannzsbb11.dll
10/01/2008  01:48 AM           868,352 oraocci11.dll
10/01/2008  02:45 AM       117,604,352 oraociei11.dll
08/12/2009  07:21 AM           413,696 OraOps11w.dll
               8 File(s)    122,249,216 bytes
               0 Dir(s)  238,127,943,680 bytes free

開発/テスト/デバッグ時に、一連の DLL が ..\projects\{Your project}\bin\Debug にコピーされます

例: [C:\Users\Legarcia\Documents\Visual Studio 2010\Projects\LabRetention\LabRetention\bin\Debug]

ユーザー向けにアプリケーションをリリースするときは、DLL を EXE の同じディレクトリにコピーするだけです。

これにより、他のすべての Ora クライアント インストールが分離されるようです。

VB.net アプリで使用される接続文字列は、他のクライアント ディレクトリにある TNSNAMES.ORA ファイルの情報から作成されます。

よろしく。

LE+

于 2014-07-31T20:04:45.657 に答える
0

OS、VS、および oracle 11g の互換性に応じて、ODAC 32/ODAC 64 ビットをダウンロードします。oracle 11g 32、os 32 ビット、oracle 32 ビットまたは oracle 64 ビット、os 64 ビットおよび oracle 11g 64 ビットを使用します。

于 2013-02-26T14:42:52.197 に答える