2012-11-05 26 views
0

我想在用戶輸入一些數據的Silverlight中創建一個ChildWindow。無論何時我致電.Show()函數,.Closed事件都會立即觸發。瀏覽器(IE8),然後一遍又一遍的拋出這個消息:Silverlight的ChildWindow.Closed事件後立即觸發.Show()

Line: 56 
Error: Unhandled Error in Silverlight Application 
Code: 2272  
Category: ParserError  
Message: Cannot find a Resource with the Name/Key PhoneDisabledBrush  
File:  
Line: 43  
Position: 155  

如果我點擊這個消息程約15倍,它最終給了我在IE瀏覽器堆棧溢出錯誤。在這條消息出現之前,我從來沒有真正看到ChildWindow被顯示,但是,在這些錯誤發生之前,它確實經歷了.Closed事件。

子窗口目前已在它沒有代碼,只增加了幾個基本的Silverlight控件(文本塊,文本框等)

的childwindow被實例化這樣的:

public TickerAdminControl() 
    { 
     InitializeComponent(); 
     winNewMsg = new windAddNewTickerMessage(); 
     winNewMsg.Closed += new EventHandler(winNewMsg_Closed); 
    } 

.Closed事件看起來像這樣:

void winNewMsg_Closed(object sender, EventArgs e) 
    { 
     if (winNewMsg.DialogResult == true) 
     { 
      TickerProxy.GetAllMessagesAsync(); 
     } 
    } 

它真的不能更基本,所以我很困惑這個錯誤。 .Show()在UserControl上的簡單按鈕單擊事件中調用。

編輯:這隻發生在IE瀏覽器。如果我使用Chrome,它將在不更改任何代碼的情況下運行。

2nd編輯:這似乎只發生在我從Visual Studio調試運行。如果我手動拉起網站(Http:// localhost:3881/Default.aspx),一切正常,這就是爲什麼它在Chrome中工作。當我手動訪問它時,它也可以在IE8中運行。我覺得我現在更加困惑。

3rd編輯:雖然在非調試中運行時一切似乎都正常工作,但錯誤仍然存​​在,但允許子窗口顯示正常運行。在左下方,我收到一條「錯誤」消息,如果我點擊它,則重複15次該錯誤:

Message: Unhandled Error in Silverlight Application Error HRESULT E_FAIL has been returned from a call to a COM component. 
at MS.Internal.XcpImports.VisualStateManager_GoToState(Control reference, String StateName, Boolean useTransitions, Boolean& refreshInheritanceContext) 
at System.Windows.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions) 
    at System.Windows.Controls.HyperlinkButton.ChangeVisualState(Boolean useTransitions) 
    at System.Windows.Controls.Primitives.ButtonBase.UpdateStateFlags(Boolean disable) 
    at System.Windows.Controls.Primitives.ButtonBase.OnIsEnabledChanged(IsEnabledChangedEventArgs e) 
    at System.Windows.Controls.Control.OnIsEnabledChanged(Control control, EventArgs args) 
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags) 
Line: 1 
Char: 1 
Code: 0 
URI: http://localhost:3881/default.aspx 

回答

0

問題已解決。原來,我在應用程序中調用了一組設置爲超鏈接按鈕的ChildWindow,它們被設置爲查找不存在的靜態資源「PhoneDisabledBrush」。這從來沒有出現過,因爲我從未將它們改爲禁用。似乎有點奇怪,VS2010不會通過編譯時例外,但我只是刪除了代碼,它工作順利。