0

I have read this post, I have followed Chris answer but it's still returning me this error. I have googled the error but could not find much solution to this error related to this error and those having the quite similar error as me points towards Chris solution. Does anyone knows what causes this error upon connecting to the oracle DB. Most of the errors are DataAccess.dll having different versions problem but mine is Object reference not set to an instance.

Well, however the problem here is that on my XE Client (11.2.0), I could run without any issue using my developing environment, there is no issue from the start on my side before I deploy to another environment. I did not even need to go through Chris solution. The Oracle.DataAccess.dll I tried both version 10.2.0.100 / 2.112.2.0 and they are working on my development side. However when it's put on the another environment (11g XE) there's an exception occurred upon .Open() and Chris solution doesn't help. Probably it's different issue here.

Also, I have connect in my main method and it has no issue. However this exception only occurs when it's connecting through my function. And I'm using the same connection for both my main and function. However I don't think the issue here is coding issue as I am able to run perfectly on my own environment.

It's running on my own environment, UAT environment but when brought onto production environment this error happens.

Dim OraconnString As String
OraconnString = ConfigurationManager.ConnectionStrings("OraConnectionString").ConnectionString
Dim OraConn As New OracleConnection(OraconnString)

Dim oracommand As OracleCommand
Dim oraadapter As New OracleDataAdapter

OraConn.Open()

I am getting this exception error upon .Open() method

  ************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at Oracle.DataAccess.Client.OracleInit.GetDllDirectory(String version)
   at Oracle.DataAccess.Client.OracleInit.Initialize()
   at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
   at WindowsApplication1.UpdateInv.UpdateInv_Load(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/******/*****/GAC_MSIL/Microsoft.VisualBasic/****/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/******/****/GAC_MSIL/System/2.0.0.0__*******/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/******/GAC_MSIL/System.Windows.Forms/2.0.0.0__*********/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/********/GAC_MSIL/System.Drawing/2.0.0.0__********/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/********/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__********/System.Runtime.Remoting.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/********/GAC_MSIL/System.Xml/2.0.0.0__********/System.Xml.dll
----------------------------------------
Oracle.DataAccess
    Assembly Version: 10.2.0.100
    Win32 Version: 10.2.0.100
    CodeBase: file:///C:/********/********/GAC/Oracle.DataAccess/10.2.0.100__********/Oracle.DataAccess.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/********/********/GAC_32/System.Data/2.0.0.0__********/System.Data.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/****/*****/GAC_MSIL/System.Configuration/2.0.0.0__********/System.Configuration.dll
----------------------------------------

Does anyone has any idea what is causing the issue or any solution to this issue?

Community
  • 1
  • 1
Sky
  • 3,350
  • 2
  • 14
  • 12
  • I think they are 2 different problems - Type Initializer vs NullReference. first step is to check that your connection string is correct - http://www.connectionstrings.com/ – Ňɏssa Pøngjǣrdenlarp May 06 '14 at 02:11
  • @Plutonix actually this error only occurs on my sub method, however on my main the connection is working perfectly. I don't think there's any wrong with coding part as it's working fine when I run on my environment. The error only occurs when it's brought to another environment. If on my main method the connection has no issue, I don't know what's the reason causing this on my sub method as they are using the same connection string. – Sky May 06 '14 at 02:20
  • 1
    I would first try to find out what that `OracleInit.GetDllDirectory` method does because that seems to be where the issue occurs. My guess would be that ODAC is not installed but it's just a guess. – jmcilhinney May 06 '14 at 03:08
  • @jmcilhinney Hmm... There's no much information available on the internet on the method. Based on the name I would guess that it's how Oracle initialize the object and try to get the DLL directory. I'm not sure if ODAC is installed on the another environment, however I guess it's installed as the first connection went through without any issue. – Sky May 06 '14 at 04:16
  • That method is probably private so is not documented. You may be able to decompile the appropriate DLL and see the source. I'm afraid I'm just guessing. – jmcilhinney May 06 '14 at 04:23

0 Answers0