调用 COM 组件时返回了错误 HRESULT E_FAIL [英] Error HRESULT E_FAIL has been returned from a call to a COM component

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

问题描述

在 Silverlight 4 应用程序中;这个错误是什么意思?:

In Silverlight 4 app; what does this error mean?:

调用 COM 组件时返回了错误 HRESULT E_FAIL."

"Error HRESULT E_FAIL has been returned from a call to a COM component."

这是一个非常普遍的错误.VS 调试器在调试时不会指向错误的确切位置.

It's a very generic error. The VS debugger doesn't point to the exact location of the error when debugging.

推荐答案

这是一个老问题,但我想我会给出我的答案,因为我通过谷歌搜索找到了这个线程来解决完全相同的问题.

This is kind of an old question, but I figured I'd give my answer since I found this thread by Googling for the exact same problem.

就我而言,我从网上复制了一些示例 XAML 以开始使用 Silverlight Toolkit 4.该示例 XAML 包含一个带有单击事件处理程序的简单按钮,该按钮与实际存在于我的程序中的任何处理程序无关.后面的代码.一开始我没有注意到这个简单的问题,因为编译器没有给我错误信息,我只是在运行时看到上面的Error HRESULT E_FAIL has been returned from a call to a COM component"信息.只有当我通过将我的示例 XAML 复制到一个没有任何其他内容的全新 Silverlight 应用程序来隔离它时,才在编译时揭示了真正的潜在问题.

In my case, I'd copied some sample XAML from the web to get started with Silverlight Toolkit 4. That sample XAML contained a simple button with a click event handler that didn't relate to any handler that actually existed in my code behind. I didn't notice this simple problem at first, because the compiler didn't give me an error message, I just saw the "Error HRESULT E_FAIL has been returned from a call to a COM component" message above at runtime. It was only when I isolated my sample XAML by copying it into a brand new Silverlight application without any other content that the real underlying problem was revealed at compile-time.

因此,如果您在运行时收到相同的错误消息,我的建议是仔细检查您的 XAML 是否有任何您预期应该在编译时发现的错误,但由于某种原因最终成为上面提到的运行时错误.为了进行调试,您可以按照我的方法进行操作,并在没有其他内容的独立 Silverlight 应用程序中隔离导致错误的代码,然后看看您是否像我一样收到更有用的错误消息来指导您.

So, if you've got the same error message at runtime, my advice is to check your XAML carefully for any errors that you had expected should have been picked up at compile time, but which for some reason ended up as the runtime error noted above. In order to debug, you can do what I did and isolate the code that's causing the error in a standalone Silverlight app with no other content, and see if like me you get a more helpful error message to guide you.

HTH.

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

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