System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

时间:2012-04-02 10:34:20

标签: c# asp.net exception

我在UserControl,页面加载中得到以下异常。我曾尝试在Google上搜索此内容,但没有找到太多信息。如果有人能帮助我,请告诉我。

情况是,有一个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事件抛出上述异常。 问候 Srividhya

1 个答案:

答案 0 :(得分:5)

我猜你在这里遇到了会话问题。您正在检查SessionController.CurrentMember != null中的Page_Load,而不是BoundAccountsOfMember中的{{1}}。

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