简体   繁体   English

使用ODP.NET部署ASP.NET网站

[英]Deploying ASP.NET website with ODP.NET

I'm writing this after following more similar questions: 在写出更多类似问题之后,我正在写这篇文章:

OracleException (0x80004005) When Connecting to Oracle Database 连接到Oracle数据库时出现OracleException(0x80004005)

The provider is not compatible with the version of Oracle client 提供程序与Oracle客户端版本不兼容

I have a small ASP.NET website which worked well in developer machine but resists itself in a Test Server. 我有一个小型的ASP.NET网站,该网站在开发人员机器上运行良好,但在测试服务器中无法使用。 When ever the App called the OracleConnection.Open(); 应用程序何时调用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 开发人员机器和测试服务器:Win 7,IIS7,Oracle Instant Client 11.2.0.4,.NET Framework 4.0 UAT和生产数据库:Oracle 9i Standard Edition我在Bin文件夹中有DLL

My objective 我的目标

Not to install Oracle Client in the Deployment machine rather just copy the DLL(s). 不要在Deployment Machine中安装Oracle Client,而只需复制DLL。

What I have tried out: 我尝试过的是:

  • I have installed the latest Microsoft Visual C++ 2012 Redistributable (x86) 我已经安装了最新的Microsoft Visual C ++ 2012 Redistributable(x86)

  • Set the project settings of Platform Target to x86 将Platform Target的项目设置设置为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). 确定要检查其是否是IIS问题,我制作了一个简单的C#Winforms应用程序,并将其与EXE一起复制了所有DLL。 I ran it when OracleConnection.Open() is called an Exception is raised and few of its properties are null. 我在调用OracleConnection.Open()时运行了它,并引发了异常,并且其少数属性为null。

In my C# Winform app, I wrote the following Code: 在我的C#Winform应用程序中,我编写了以下代码:

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. 当我运行上述应用程序时,发生异常,但是由于异常的错误消息,错误号和错误源的属性值为null,因此我收到“对象引用未设置为类的实例”错误。 ie Oracle.DataAccess.Client.OracleException.get_Number() 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. 有关调用即时(JIT)调试而不是此对话框的详细信息,请参见此消息的末尾。

************** 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. “ / JksbBoWeb2”应用程序中的服务器错误。

Unhandled Execution Error Description: An unhandled exception occurred during the execution of the current web request. 未处理的执行错误说明:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

Exception Details: Oracle.DataAccess.Client.OracleException: 异常详细信息:Oracle.DataAccess.Client.OracleException:

Source Error: 源错误:

An unhandled exception was generated during the execution of the current web request. 当前Web请求的执行期间生成了未处理的异常。 Information regarding the origin and location of the exception can be identified using the exception stack trace below. 可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

Stack Trace: 堆栈跟踪:

[OracleException (0x80004005)] [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.HandleErrorHelper(Int32 errCode,OracleConnection conn,IntPtr opsErrCtx,OpoSqlValCtx * pOpoSqlValCtx,对象src,字符串过程,布尔bCheck)+1467
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +24 Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,OracleConnection conn,IntPtr opsErrCtx,Object src)+24
Oracle.DataAccess.Client.OracleConnection.Open() +4444 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 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.Util.CalliEventHandlerDelegateProxy.Callback(对象发件人,EventArgs e)+51 System.Web.UI.Control.OnLoad(EventArgs e)+92
System.Web.UI.Control.LoadRecursive() +54 System.Web.UI.Control.LoadRecursive()+54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+772

-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; -------------------------------------------------- ------------------------------版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET Version:4.0.30319.18408 ASP.NET版本:4.0.30319.18408

Ok thinking whether I have missed anything in my webconfig, I am posting same 好吧,我是否想在Webconfig中错过任何内容,我正在发布相同内容

<?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>

To make it easy: you can't. 简单起见:您做不到。 ODP.NET (Oracle.DataAccess.Client) uses OCI, the library from Oracle that handles the actual connection. ODP.NET(Oracle.DataAccess.Client)使用OCI(Oracle的库来处理实际的连接)。 That isn't a .NET assembly, it's in C++. 那不是.NET程序集,而是C ++。 ODP.NET is just a wrapper to call OCI. ODP.NET只是调用OCI的包装。 That is why you have to install the Client tools. 这就是为什么您必须安装客户端工具的原因。

But there is more. 但是还有更多。 Oracle has release Managed ODP.NET , which is a full implementation of the protocol (rather than just having a wrapper to OCI). Oracle已发布Managed ODP.NET ,它是该协议的完整实现(而不仅仅是OCI的包装器)。 That means you don't have to install the Client tools, you just have to include that single assembly and you are done! 这意味着您不必安装客户端工具,只需要包括该单个程序集就可以了!

Solved the problem. 解决了问题。

I identified an Old Oracle 9i client had been installed in the deployment server and such causing a conflict to what ever dll's related to the Oracle deployment. 我确定在部署服务器中已安装了Old Oracle 9i client ,从而导致与Oracle部署相关的dll发生冲突。 I simply uninstall the Oracle 9i client, removed references in PATH and finally deleted the HKLM\\SOFTWARE\\ORACLE key in registry and it worked! 我只需要卸载Oracle 9i客户端,删除PATH中的引用,最后删除注册表中的HKLM\\SOFTWARE\\ORACLE项就可以了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM