title: VB.NET issue connecting to Oracle 11g
body: <pre><code>OS: Windows 7 64bit
  VB: Visual Studio 2010
  Oracle Client: 11g
  </code></pre>
  
  <p>I am developing an application that connects to an Oracle 11g server.  I am able to connect to the Oracle server via Oracle SQL Developer, ODBC (in SYSWOW64), and in VB Server Explorer.</p>
  
  <p>I am using the .NET reference Oracle.DataAccess located at: C:\Oracle\product\11.2.0\client_32\ODP.NET\bin\2.x\Oracle.DataAccess.dll</p>
  
  <p>I have tried adding the .DLL files to my bin folder as suggested by other questions and that does not work.</p>
  
  <p>Does anyone have any other suggestions?</p>
  
  <p>When I run my application, I get the following:
  <img src="https://i.stack.imgur.com/3tL2k.jpg" alt="enter image description here"></p>
  
  <p>Here are the details:</p>
  
  <pre><code>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&amp; m, MouseButtons button, Int32 clicks)
         at System.Windows.Forms.Control.WndProc(Message&amp; m)
         at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
         at System.Windows.Forms.Button.WndProc(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
         at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
         at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; 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: 
  </code></pre>
  
  <p>VB.NET Code:</p>
  
  <pre><code>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)  '&lt;--- 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
  </code></pre>