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

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

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

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.

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.

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.


There are many solutions out there but this is the only solution that worked several times for me.It has been tried on VS2012 VS2013 and VS2015, I find it working equally good for all.Just follow steps bellow to fix this issue

Step 1 : Close Visual Studio
Step 2 : Delete *.csproj.user and *.suo files
Step 3 : Reopen VS, and try to run project again in debug mode.

NOTE : This situation occurs when multiple users working on same project with different VS versions .suo file is not supported for round-tripping between the two VS versions.It contains information about what settings current user has selected for his/hers VS working environment.


In my situation:

I create a

class MyControl : ContentControl {
}

By default, the class is not public and XAML cannot load it and throw exception

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

Just change the scope of class to public and error disappear.

Hope this help.

PS. Microsoft should provide more on information than just throw a mystery error message without any stack trace.


I also had this error and I found that this problem is related to not have added all requiered assemblies to your project. In my case I was using a UserControl with a depency with the Silverlight Toolkit and I havent added this reference. I just added the reference and everything solved :)


I had this error using the current SL4 Telerik controls. A similar issue has been reported here with a solution ... of sorts. The problem seems to be with the way Expression Blend manages the cache of controls.