Vid*_*dya 0 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)
Run Code Online (Sandbox Code Playgroud)
请求信息:已通过身份验证:True身份验证类型:表单线程帐户名称: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;
}
}
Run Code Online (Sandbox Code Playgroud)
请找到后面的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;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的异常是从Page_Load事件抛出的.关心Srividhya
我猜你在这里遇到了会话问题.你检查SessionController.CurrentMember != null的Page_Load,但不是在你的BoundAccountsOfMember.
如果你说它不时发生,我认为这是一个问题.您可能应该在模块中处理会话续订/失效,以确保您的代码在没有有效会话的情况下无法运行.