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

77,116

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

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 :)

Solution 5

I had this error in my xaml page and there were no syntax errors. Cleaning and re-building the project solved my issue. fyi...

Share:
77,116

Related videos on Youtube

luoluuuo
Author by

luoluuuo

Just another curious nerd.

Updated on March 03, 2022

Comments

  • luoluuuo
    luoluuuo about 2 years

    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.

  • dcstraw
    dcstraw about 13 years
    That's one specific instance of the error, but it occurs in many situations in Silverlight, especially when there are problems with the XAML of a merged dictionary.
  • RaoulRubin
    RaoulRubin over 12 years
    This question is not going to have a simple answer. You need to double check everything and look for incosistancies.
  • jv42
    jv42 about 12 years
    I think the OP (as myself) is having the problem on runtime, not design time.
  • Davut Gürbüz
    Davut Gürbüz about 12 years
    You are right its a generic error. If you do device-related things. Maybe running project on release mode solve the issue. It fails sometimes on debug mode. Just run it using Ctrl+F5.As you said its a very common error, some of them listed here msdn.microsoft.com/en-us/library/windows/desktop/…
  • jv42
    jv42 about 12 years
    Nope, I have failures in Release code sadly. This is inside some media playback in native code.
  • Davut Gürbüz
    Davut Gürbüz about 12 years
    Is there any code such as 0xFF2.... , Silverlight supported some formats only listed here,I had similar issue ,msdn.microsoft.com/en-us/library/cc189080%28v=vs.95%29.aspx
  • jv42
    jv42 about 12 years
    This is a very random error, I think it occurs only during some internal startup and cleanup code, not during actual playback. Thanks for the help anyway ;)
  • coarist
    coarist almost 7 years
    In my case this problem showed up after using an older version code project. It did not occur at the first instance but some time afterwards. No editing option is presented by the VS GUI so it turned very uneasy. The program can still compile, run and debug, only that the Designer cannot display the affected WinForm. I followed these steps and it solved my problem. Visual Studio 2017 Community , the .suo file is located: ProjectName\ .vs \ProjectName\ v15
  • user1867382
    user1867382 almost 5 years
    Add 2019 to the list of things this fixes :)
  • forestgril
    forestgril over 3 years
    In my case I've been trying to parse-open a LLVM build and haven't seen any of the mentioned .user nor .suo files. Simply closing an reopening MS VS 2019 fixed this issue. Thanks!