I'm writing this after following more similar questions:
OracleException (0x80004005) When Connecting to Oracle Database
The provider is not compatible with the version of Oracle client
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:
In my machine (Developer Machine) it worked like a charm, but On a Test Server it did not work well.
My Specs
Developer Machine & Test Server: Win 7, IIS7, Oracle Instant Client 11.2.0.4, .NET Framework 4.0 UAT & Production DB: Oracle 9i Standard Edition I'm having the DLL(s) in the Bin folder
My objective
Not to install Oracle Client in the Deployment machine rather just copy the DLL(s).
What I have tried out:
I have installed the latest Microsoft Visual C++ 2012 Redistributable (x86)
Set the project settings of Platform Target to x86
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.
In my C# Winform app, I wrote the following 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));
}
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. Oracle.DataAccess.Client.OracleException.get_Number()
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** 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& 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: 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:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
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.
Server Error in '/JksbBoWeb2' Application.
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.
Exception Details: Oracle.DataAccess.Client.OracleException:
Source Error:
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.
Stack Trace:
[OracleException (0x80004005)]
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) +1467
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +24
Oracle.DataAccess.Client.OracleConnection.Open() +4444
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
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
Ok thinking whether I have missed anything in my webconfig, I am posting same
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImageHandler" />
<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" />
</handlers>
</system.webServer>
<system.web>
<httpHandlers>
<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" />
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<connectionStrings>
<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"/>
<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"/>
</connectionStrings>
</configuration>