开发者

How to trace Error on a Deployed ASP.Net Application?

VS 2008 / ASP.Net

I have a deployed a ASP.Net Web Application on Windows 2003 Server. For some reasons, it throws an error.

Application works great on my local computer. Either from source code or hosted on my local machine (Windows XP).

How to trace error on a deployed ASP.Net Web Application ?

Error :

Object reference not set to an instance of an object. 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: System.NullReferenceException: Object reference not set to an instance of an object.

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:

[NullReferenceException: Object reference not set to an instance of an object.]
   _Default.ExportRx30ToSalisburyAccessDB() +351
   _Default.Button1_Click(Object sender, EventArgs e) +5
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Source code : Which i am facing this error ..

try {

        Access.Application access1 = new Access.Application();

        // Open the Access database for exclusive access
        string sSalisburyAccessDB = Server.MapPath("~/App_Data/Salisbury.mdb");

        access1.OpenCurrentDatabase(sSalisburyAccessDB, true, null);

        // Drop the existing table data

        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "drug");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "patplan");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "plans");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "price");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "rx");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "patient");
        access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "plntrak");

        // Run the saved import
        access1.DoCmd.RunSavedImportExport("SalisburyODBC");

        // Close the database
  开发者_运维知识库      access1.CloseCurrentDatabase();

        // Quit MS Access
        access1.Quit(Access.AcQuitOption.acQuitSaveAll);

        Response.Write("successful");

    }
    catch (Exception ex)
    {
        Response.Write(ex.InnerException.Message);
    }


Try running your app in IIS Express instead of Cassini (the built-in Visual Studio development web server). They behave differently and you might have a better shot at recreating the issue in your development environment. IIS Express runs just like real IIS so there are fewer surprises when you deploy your application.


Try deploying the application in debug mode, which should give you a specific line number and code file where the error occurred. Simply place this in your web.config file:

<configuration>
  <system.web>
    <compilation debug="true">
  </system.web>
</configuration>

However, in general, you do not want to deploy to final production in debug mode. Instead, make use of try...catch blocks and good status/exception logging in your application to track down problems.


The easiest way to find where such errors occur is to split your methods down to just do one thing per method. For example, instead of adding a comment that say // Run the saved import, make a method of it RunTheSavedImport() and you will much easier be able to detect in which part of the code the error occurs directly from the stack trace.

What I can see , if the code you have provided is the full ExportRx30ToSalisburyAccessDB-method, the most probable causes for this error is that either DoCmd, AcQuitOption or AcObjectType of some reason are null. Since the stack do not enter Application it can only be caused by objects inside this method.


[ObjectDisposedException: Cannot access a closed resource set.] System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString) +1657 System.Resources.RuntimeResourceSet.GetString(String key, Boolean ignoreCase) +12 System.Resources.ResourceManager.GetString(String name, CultureInfo culture) +78 SourceCode.Workspace.OOBReports.ReportList.CreateChildControls() +347 System.Web.UI.Control.EnsureChildControls() +146 System.Web.UI.Control.PreRenderRecursiveInternal() +61 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

simply reset your IIS server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜