【问题标题】:System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)System.Web.UI.Page.ProcessRequestMain(布尔型 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint)
【发布时间】:2012-04-02 10:34:19
【问题描述】:

我在用户控件页面加载中遇到以下异常。我试过在谷歌上搜索这个,但没有找到太多信息。请让我知道是否有人可以帮助我。

情况是,不同语言的各种用户控件都有一个 ascx.cs 文件。

应用程序运行正常,但有时会抛出此异常。

Exception information: 
Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object.
at SmartSoft.SmartLiveWeb.UserControls.Common.PayoutForms.BoundAccountsOfMember()
at SmartSoft.SmartLiveWeb.UserControls.Common.PayoutForms.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

请求信息: 已认证:真 身份验证类型:表格 线程账号名:IIS APPPOOL\SLC网站

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                /*
                if (Request.QueryString.Count > 0 && Request.QueryString["MId"] != null)
                    this.MId = int.Parse(Request.QueryString.Get("MId"));
                */

                HideAllForms();
                AddValidationAttributesToControls();
                **BoundAccountsOfMember();**
                BoundWithdrawMethods();
                /*
                 * if (IsNetentConfirmationRequired())
                    LoadNetentConfirmationForm();
                 * 
                */
                CurrentPayoutMethod = (PayoutMethodEnum)Convert.ToInt16(SessionController.GetSessionData<object>("PayoutMethod"));
            }

            PlaceHolder phWithdraw = this.FindControl("phWithdraw") as PlaceHolder;
            Panel pnlKYC = this.FindControl("pnlKYC") as Panel;

            if (SessionController.CurrentMember != null && SessionController.CurrentMember.Approved == 10)
            {
                phWithdraw.Visible = false;
                pnlKYC.Visible = true;
            }
            else
            {
                phWithdraw.Visible = true;
                pnlKYC.Visible = false;
            }
        }

请在后面找到BoundAccountsofMember方法代码。

private void BoundAccountsOfMember()
        {
            Dictionary<Int16, AccountType> accountTypes = SessionController.CurrentMember.GetAccountTypes();

            ddlWithdrawFrom.Items.Clear();
            foreach (AccountType accountType in accountTypes.Values)
            {
                ddlWithdrawFrom.Items.Add(new ListItem(accountType.AccountName, accountType.AccountId.ToString()));
            }
            ListItem li = ddlWithdrawFrom.Items.FindByValue(SessionController.DefaultAccountId.ToString());
            if (li != null)
            {
                ddlWithdrawFrom.SelectedIndex = -1;
                li.Selected = true;
            }
        }

上述异常是从 Page_Load 事件中引发的。 问候 斯里维迪亚

【问题讨论】:

    标签: c# asp.net exception


    【解决方案1】:

    我猜你这里的会话有问题。您在Page_Load 中检查SessionController.CurrentMember != null,但不在BoundAccountsOfMember 中。

    如果您说它不时发生,我认为这是一个问题。您可能应该在模块中处理会话更新/失效,以确保您的代码在没有有效会话的情况下不会运行。

    【讨论】:

      猜你喜欢
      • 2017-10-15
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 2013-11-29
      相关资源
      最近更新 更多