question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhelpful error message when invalid resource key

See original GitHub issue

Describe the bug Was trying to launch my application and getting a Error HRESULT E_FAIL has been returned from a call to a COM component. message on start with no additional information or stacktrace as to what the problem was.

Turned out, I had a StaticResource key referencing something that didn’t exist by mistake. It’d be great if VS could point this out ahead of time or the runtime error message be more useful here for debugging.

E.g.

<Style x:Key="TokenizingTextBoxItemTokenStyle" TargetType="controls:TokenizingTextBoxItem">
...
</Style>

<Style TargetType="controls:TokenizingTextBoxItem" BasedOn="{StaticResource TokenizingTextBoxItemStyle}"/>

See the mismatch above in the Key to StaticResource lookup.

Expected behavior Error message calling out no resource found with given key would at least be a pointer.

Error Details

System.Runtime.InteropServices.COMException
  HResult=0x80004005
  Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Version Info

Windows 10 version Saw the problem?
Insider Build (19615) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT

Additional context Thought I had maybe filed a similar bug before, but couldn’t find it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
michael-hawkercommented, Jan 4, 2021

Hit another case where I just got a unhelpful:

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

Coming from the ResourceDictionary type itself.

It was a case where I was trying to assign the wrong type of resource to another resource…

    <ResourceDictionary>
        <SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{StaticResource RainbowBrush}" />

RainbowBrush in this case was a LinearGradientBrush, so loading this ResourceDictionary was failing at runtime, no indication that this was a problem or pointing me in the right direction… ☹

1reaction
fabiant3commented, May 6, 2020

Is this managed or C++? There should be stowed exceptions with more info (you might need to turn on mixed debugging). As for the original issue I had a resource that it did not really exist, we had planned to make changes to our compiler pipeline to detect these cases and give you a compile time error (similar for Binding and other related misfires).
Unfortunately this will only happen post WinUI 3.0, currently we’re shooting for tooling parity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure - "Invalid Resource" message while trying to create a ...
I am trying to create an Azure Storage account using the Azure Resource Manager Connector in Logic Apps. But I am getting an...
Read more >
Invalid resource name and type segments - Azure
Describes how to resolve an error when the resource name and type don't have the same number of segments.
Read more >
User authorization failure with error "Invalid resource ...
On MacOS: press "fn + command + f2" keys; On Windows: press "Ctrl + F2" keys. question details.
Read more >
Assertion Consumer Service URL tag not checked for invalid ...
Warning: Invalid resource key: The value of attribute "AssertionConsumerServiceURL" associated with an element type "samlp:AuthnRequest" must ...
Read more >
3240175 - 'Invalid resource url' error in SAP API Management
In API Logs, you can see the following error: Failed to load resource: the server responded with a status of 400 (Bad Request)Log-dbg....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found