奇怪的错误:对象引用未设置为对象的实例

时间:2013-02-25 10:16:26

标签: c# asp.net

我有时会在实时应用中遇到错误。

堆栈追踪:

  

在Tool.User_RequestSender.Page_Load(Object sender,EventArgs e)中   d:\ Site \ Tool \ User \ RequestSender.aspx.cs:第72行   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object   o,对象t,EventArgs e)at   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,   EventArgs e)在System.Web.UI.Control.OnLoad(EventArgs e)at   System.Web.UI.Control.LoadRecursive()at   System.Web.UI.Page.ProcessRequestMain(布尔   includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

我一次又一次地尝试运行我的机器代码,但无法得到同样的错误。

即使是现场代码,我也会遇到这个问题。

Request_Sender.aspx.cs中的Page_Load代码:

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                this.LoadRequest();
            }
        }
        catch (CustomException ex)
        {
            this.ShowMessage(ex.Message);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

LoadRequest()如下:

private void LoadRequest()
    {
        Credential credential;


            if (
                !string.IsNullOrEmpty(Request["typeOfrequest"]) &&
                !string.IsNullOrEmpty(Request["empUserId"]) &&
                !string.IsNullOrEmpty(Request["applicationId"])
               )
            {
                // Get details of credentials
                credential = (new RequestManager()).GetCredential(this.EmpUserId, this.ApplicationId, (int)this.TypeOfrequest);
                this.applicaionRequest = new Request
                {
                    RequestType = this.TypeOfrequest,
                    RequestStatus = Enumerations.RequestStatus.Sent,
                    Application = credential.Application,

                    EmpUserId = credential.EmpUserId,
                    EmployeeId = credential.EmployeeId,
                    Username = credential.Username,

                    SenderAddress = Security.CurrentUser.Details.EmailAddress,
                    ReceiverAddress = (new Datastore.RequestStore()).GetReceiverAddress((int)this.TypeOfrequest, this.ApplicationId),
                    AddedBy = Security.CurrentUser.Details.UserId
                };
                    ucSendRequest.ApplicationRequest = applicaionRequest;

            }
            else
            {
                Response.Write("Invalid request!");
                Response.End();
            }
        }

    }

1 个答案:

答案 0 :(得分:0)

错误明确指出应用程序执行期间smth为null

要获得任何帮助,您应该检查nullRequest中的LoadRequest()是否是一个好的候选者),或者更好的解决方案,修改您的catch博客以记录哪些参数导致应用程序崩溃。