2011-08-14 52 views
0

以下例外情況:引發未知異常而沒有內部異常?

異常:執行命令定義時發生錯誤。
查看

的內部例外

並且沒有內部異常。

bool IsVerifyingPassword 
{ 
    get 
    { 
     return (bool?)ViewState["IsDoubleCheckPassword"] ?? false; 
    } 
    set { ViewState["IsDoubleCheckPassword"] = value; } 
} 

哪裏是我的錯:

從以下代碼從getter方法拋出?

+0

是指從吸氣或設置方法拋出? –

+0

@FredrikMörk:Getter –

+0

沒有堆棧跟蹤? –

回答

2

試用:

bool IsVerifyingPassword 
{ 
    get 
    { 
     bool returnValue = false; 
     object viewStateValue = ViewState["IsDoubleCheckPassword"];   
     if (viewStateValue != null) 
     {   
      // stay false if not able to retrieve bool from ViewState 
      bool.TryParse(viewStateValue.ToString(), out returnValue); 
     } 

     return returnValue; 
    } 

如果房產真的應該爲空的布爾則:

bool? IsVerifyingPassword 
{ 
    get 
    { 
     object viewStateValue = ViewState["IsDoubleCheckPassword"];   
     if (viewStateValue != null) 
     { 
      bool returnValue = false; 

      // stay false if not able to retrieve bool from ViewState 
      bool.TryParse(viewStateValue.ToString(), out returnValue); 
      return returnValue; 
     }else 
     { 
      return null; 
     } 
    }