错误HRESULT E_FAIL已从对COM组件的调用返回? [英] Error HRESULT E_FAIL has been returned from a call to a COM component?

查看:53
本文介绍了错误HRESULT E_FAIL已从对COM组件的调用返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在Silverlight弹出窗口时遇到麻烦.当我单击一个按钮打开它会引发该错误.我在这里粘贴代码.

Hi,
I am having a trouble with a pop up in silverlight. When i click on a button to open it throws the that error. Here i am pasting code .

<popup x:name="PopupNotification" verticaloffset="-400" horizontaloffset="200" xmlns:x="#unknown">
            <border removed="{StaticResource PanelBrush}" cornerradius="5" borderbrush="Black" margin="2,2,2,1">
                <!--<stackpanel orientation="Vertical">-->
                <usercontrols:notification x:name="UserControlNotification" xmlns:usercontrols="#unknown"></usercontrols:notification>
                <!--<stackpanel orientation="Horizontal" horizontalalignment="Center">
                        <Button Content="Ok"  Width="50" HorizontalAlignment="Right" Margin="0,4,4,4" Click="btnNotificationOK_Click"  x:Name="btnNotificationOK"/>
                        <Button Content="Cancel" Width="50" HorizontalAlignment="Right" Margin="10,4,4,4" Click="btnNotificationCancel_Click"  x:Name="btnNotificationCancel"/>
                    </stackpanel>-->
                <!--</stackpanel>-->
            </border>
        </popup>



当单击按钮时,在其后面的代码中单击将在此处引发错误.



and when on button click in code behind it throws error here.

PopupNotification.IsOpen = true;

推荐答案

我注意到您的弹出窗口包含对用户控件的引用.以我的经验,当发生此错误时,这是​​子控件中的问题,而不是实际产生错误的级别.弹出窗口可能是正确创建的,但是在运行时尝试创建用户控件时,它将失败.用户控件可能会生成运行时异常,即弹出窗口正在捕获,但只是冒泡为COM错误.我想如果您查看堆栈跟踪,就会看到用户控件的构造函数有异常.

尝试将用户控件放在主应用程序页面上并将其实例化.我敢打赌,那里也会引发错误.如果它在同一个项目中,您将能够对其进行调试(已提供SL调试它的设置)并找到错误.如果它在另一个项目中,则必须设置一个测试页并在那里进行调试.

记住,使用用户控件在XAML中也可能是一个问题.诸如引用控件模板中的静态资源(在运行时不可用)这样的简单操作可能会导致用户控件中出现异常.隔离和测试是跟踪这些错误的关键.
I notice that your popup contains a reference to a user control. In my experience, when this error occurs it is a problem in a child control and not at the level where the error is actually generated. The popup is likely being created correctly but when the runtime tries to create the usercontrol, it is failing. The usercontrol is likely generating a runtime exception that the popup is trapping, but is simply bubbling up as a COM error. I imagine if you look at the stack trace, you''ll see the exception is on the constructor of the user control.

Try dropping the usercontrol on the main app page and instantiating it. I bet it throws an error there as well. If it is in the same project, you''ll be able to debug it (provided SL debugging it setup) and find the error. If it is in another project, you''ll have to setup a test page and debug it there.

Remember, with user controls it can be a problem in the XAML as well. Something as simple as referencing a static resource in the control template that isn''t available at runtime can cause an exception in the user control. Isolation and testing is the key to tracking these bugs down.


这篇关于错误HRESULT E_FAIL已从对COM组件的调用返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆