Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Silverlight ChildWindow.Closed事件在.Show()之后立即激发_C#_Silverlight - Fatal编程技术网

C# Silverlight ChildWindow.Closed事件在.Show()之后立即激发

C# Silverlight ChildWindow.Closed事件在.Show()之后立即激发,c#,silverlight,C#,Silverlight,我试图在silverlight中创建一个ChildWindow,供用户输入一些数据。每当我调用.Show()函数时,.Closed事件立即触发。然后浏览器(IE8)反复抛出此消息: Line: 56 Error: Unhandled Error in Silverlight Application Code: 2272 Category: ParserError Message: Cannot find a Resource with the Name/Key Phone

我试图在silverlight中创建一个ChildWindow,供用户输入一些数据。每当我调用
.Show()
函数时,
.Closed
事件立即触发。然后浏览器(IE8)反复抛出此消息:

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控件(textblock、TextBox等)

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();
        }
    }
这实在是太基本了,所以我对这个错误感到困惑。在UserControl上的一个简单按钮单击事件中调用
.Show()

编辑:这只发生在IE上。如果我使用Chrome,它不会改变任何代码

第二次编辑:这似乎只发生在我从VisualStudio运行调试时。如果我手动打开站点(Http://localhost:3881/Default.aspx)一切正常,这就是为什么它在Chrome中工作。当我手动访问它时,它也可以在IE8中工作。我想我现在更糊涂了

第三次编辑:当在非调试模式下运行时,一切看起来都正常工作,但错误仍然存在,但允许子窗口显示操作正常。在左下角,我收到一条“错误”消息,如果我单击它,它会重复此错误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

问题解决了。原来我在调用ChildWindow的应用程序上有一组样式化的超链接按钮,它们被设置为查找不存在的静态资源“PhoneDisabledBrush”。这以前从未出现过,因为我从未将它们改为残疾人。VS2010没有通过编译时异常似乎有点奇怪,但我只是删除了代码,它工作得很顺利