Windows Phone 8 Service Call causes Error HRESULT

2019-09-10 04:07发布

问题:

When making a typical Service Call it is causing an error Error HRESULT E_FAIL has been returned from a call to a COM component

var response = await ServiceManager.SendRequestAsync<GetOptionsResponse>(request);

This error is only occurring when I make a service call from this page, if I call the same method from another page it works fine.

The error causes the response to not be returned and the whole App crashes.

Any ideas?

回答1:

It turns out that it actually wasn't the Service Call, just any method that was awaited allowing, the Main UI thread to return to loading the Page.

When the page was loaded there was an error in the XAML that caused the entire App to Crash.

Turns out it was this line in the xaml

FontWeight=" {Binding Path=SatisfactionSurveyStyles.SelectedListBoxItemFontWeight, Source={StaticResource LocalizationFiles}}"

There should be no space between " {

FontWeight="{Binding Path=SatisfactionSurveyStyles.SelectedListBoxItemFontWeight, Source={StaticResource LocalizationFiles}}"

I removed the space and it works fine now, since XAML errors aren't picked up by the Compiler it was hard to track down, also since Microsoft is notorious for misleading Error Messages when I read

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

It wasn't very helpful. Anyways it works now, lesson learned, spaces can be deadly... >)