title: Deploying ASP.NET website with ODP.NET
body: <p>I'm writing this after following more similar questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/20646800/oracleexception-0x80004005-when-connecting-to-oracle-database">OracleException (0x80004005) When Connecting to Oracle Database</a></p>
  
  <p><a href="https://stackoverflow.com/questions/659341/the-provider-is-not-compatible-with-the-version-of-oracle-client">The provider is not compatible with the version of Oracle client</a></p>
  
  <p>I have a small ASP.NET website which worked well in developer machine but resists itself in a Test Server. When ever the App called the OracleConnection.Open(); I get an rather helpless "Unhandled Execution Error". The full description is below:</p>
  
  <p>In my machine (Developer Machine) it worked like a charm, but On a Test Server it did not work well.</p>
  
  <p><strong>My Specs</strong></p>
  
  <p>Developer Machine &amp; Test Server: Win 7, IIS7, Oracle Instant Client 11.2.0.4, .NET Framework 4.0
  UAT &amp; Production DB: Oracle 9i Standard Edition
  I'm having the DLL(s) in the Bin folder</p>
  
  <p><strong>My objective</strong> </p>
  
  <p>Not to install Oracle Client in the Deployment machine rather just copy the DLL(s).</p>
  
  <p><strong>What I have tried out:</strong></p>
  
  <ul>
  <li><p>I have installed the latest Microsoft Visual C++ 2012  Redistributable (x86)</p></li>
  <li><p>Set the project settings of Platform Target to x86</p></li>
  <li><p>Ok to check whether its an IIS issue, I made a simple C# Winforms application and its alongside its EXE I have copied all DLL(s). I ran it when OracleConnection.Open() is called an Exception is raised and few of its properties are null.</p></li>
  </ul>
  
  <p>In my C# Winform app, I wrote the following Code:</p>
  
  <pre><code>private void btnConnect_Click(object sender, EventArgs e)
          {
  
              string conStr = string.Format(oraConStr, txtHost.Text, txtPwd.Text, txtUser.Text);
              using (OracleConnection con = new OracleConnection(conStr))
              {
                  LogMessage(conStr);
                  try
                  {
                      con.Open();
                      MessageBox.Show("Connected");
                  }
                  catch (OracleException OraEr)
                  {
                      displayOracleErrorMessage(OraEr);
                  }
                  catch (Exception Er)
                  {
                      MessageBox.Show(Er.Message);
                  }
              }
  
  
          }
  
          private void displayOracleErrorMessage(OracleException er)
          {
              MessageBox.Show(string.Format("Error {0}\nError Number {1}\nStack Trace{1}", er.Message, er.Number, er.StackTrace));
          }
  </code></pre>
  
  <p>When I run the above app, an Exception occurs but the Exception have null value in its properties of Error Message, Error Number and Error Source as a result of it I get an "Object Reference not set to an instance of a class" error. i.e. <code>Oracle.DataAccess.Client.OracleException.get_Number()</code></p>
  
  <p>See the end of this message for details on invoking 
  just-in-time (JIT) debugging instead of this dialog box.</p>
  
  <pre><code>************** Exception Text **************
  System.NullReferenceException: Object reference not set to an instance of an object.
     at Oracle.DataAccess.Client.OracleException.get_Number()
     at OracleConnectionChecker.Form1.displayOracleErrorMessage(OracleException er) in d:\TEMP\Test 2013\Projects\OracleConnectionChecker\OracleConnectionChecker\Form1.cs:line 54
     at OracleConnectionChecker.Form1.btnConnect_Click(Object sender, EventArgs e) in d:\TEMP\Test 2013\Projects\OracleConnectionChecker\OracleConnectionChecker\Form1.cs:line 41
     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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  
  
  ************** Loaded Assemblies **************
  mscorlib
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
  ----------------------------------------
  OracleConnectionChecker
      Assembly Version: 1.0.0.0
      Win32 Version: 1.0.0.0
      CodeBase: file:///C:/Executable/Debug/OracleConnectionChecker.exe
  ----------------------------------------
  System.Windows.Forms
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
  ----------------------------------------
  System.Drawing
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
  ----------------------------------------
  System
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
  ----------------------------------------
  Oracle.DataAccess
      Assembly Version: 4.112.4.0
      Win32 Version: 4.112.4.0
      CodeBase: file:///C:/Executable/Debug/Oracle.DataAccess.DLL
  ----------------------------------------
  System.Data
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
  ----------------------------------------
  System.Core
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
  ----------------------------------------
  System.Transactions
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
  ----------------------------------------
  System.Configuration
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
  ----------------------------------------
  System.Xml
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
  ----------------------------------------
  System.EnterpriseServices
      Assembly Version: 4.0.0.0
      Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
      CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
  ----------------------------------------
  
  ************** JIT Debugging **************
  To enable just-in-time (JIT) debugging, the .config file for this
  application or computer (machine.config) must have the
  jitDebugging value set in the system.windows.forms section.
  The application must also be compiled with debugging
  enabled.
  
  For example:
  
  &lt;configuration&gt;
      &lt;system.windows.forms jitDebugging="true" /&gt;
  &lt;/configuration&gt;
  
  When JIT debugging is enabled, any unhandled exception
  will be sent to the JIT debugger registered on the computer
  rather than be handled by this dialog box.
  </code></pre>
  
  <blockquote>
    <h2>Server Error in '/JksbBoWeb2' Application.</h2>
    
    <p>Unhandled Execution Error  Description: An unhandled exception
    occurred during the execution of the current web request. Please
    review the stack trace for more information about the error and where
    it originated in the code. </p>
    
    <p>Exception Details: Oracle.DataAccess.Client.OracleException: </p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace: </p>
    
    <p>[OracleException (0x80004005)]<br>
    Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
    errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
    pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) +1467<br>
    Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
    OracleConnection conn, IntPtr opsErrCtx, Object src) +24<br>
    Oracle.DataAccess.Client.OracleConnection.Open() +4444<br>
    JksbBoWeb2.Default.getMainDataSet(DateTime pStartDate, DateTime
    pEndDate) +296    JksbBoWeb2.Default.btnToday_Click(Object sender,
    EventArgs e) +133    JksbBoWeb2.Default.Page_Load(Object sender,
    EventArgs e) +28<br>
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
    EventArgs e) +51    System.Web.UI.Control.OnLoad(EventArgs e) +92<br>
    System.Web.UI.Control.LoadRecursive() +54<br>
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    +772</p>
    
    <p>-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319;
    ASP.NET Version:4.0.30319.18408</p>
  </blockquote>
  
  <p>Ok thinking whether I have missed anything in my webconfig, I am posting same</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    --&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" /&gt;
    &lt;/appSettings&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;handlers&gt;
        &lt;remove name="ChartImageHandler" /&gt;
        &lt;add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
          path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
      &lt;/handlers&gt;
    &lt;/system.webServer&gt;
    &lt;system.web&gt;
      &lt;httpHandlers&gt;
        &lt;add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          validate="false" /&gt;
      &lt;/httpHandlers&gt;
      &lt;pages&gt;
        &lt;controls&gt;
          &lt;add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
            assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
        &lt;/controls&gt;
      &lt;/pages&gt;
      &lt;compilation debug="true" targetFramework="4.0"&gt;
        &lt;assemblies&gt;
          &lt;add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;/assemblies&gt;
      &lt;/compilation&gt;
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"/&gt;
      &lt;/authentication&gt;
      &lt;authorization&gt;
        &lt;deny users="?"/&gt;
      &lt;/authorization&gt;
    &lt;/system.web&gt;
    &lt;connectionStrings&gt;
      &lt;add name="ora.prod.jksb.com" connectionString="DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=x)(PORT=1521)))(CONNECT_DATA=(SID = ORCL)));PASSWORD=x;USER ID=x;" providerName="Oracle.DataAccess.Client"/&gt;
      &lt;add name="ora.uat.jksb.com" connectionString="DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=x)(PORT=1521)))(CONNECT_DATA=(SID = ORCL)));PASSWORD=x;USER ID=x;" providerName="Oracle.DataAccess.Client"/&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>