Bug 39826 - XamlC target causes "Error HRESULT E_FAIL has been returned from a call to a COM component." dialog when using "Run Custom Tool" on a XAML file in a UWP project
Summary: XamlC target causes "Error HRESULT E_FAIL has been returned from a call to a ...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.1.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-22 01:40 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-04-14 19:28 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-03-22 01:40:22 UTC
XamlC target causes "Error HRESULT E_FAIL has been returned from a call to a COM component." dialog when using "Run Custom Tool" on a XAML file in a UWP project




## Steps to replicate

1. Create a new "Visual C# -> Windows -> Universal -> Blank App (Universal Windows)" in VS 2015 Update 1 on Windows 10. (I used the default ".NET Framework 4.5.2" in the target framework drop-down.)

2. Install the Xamarin.Forms 2.1.0.6529 NuGet package into the project.

3. Close and reopen the solution.

4. Right-click the "App.xaml" file in the UWP project and select "Run Custom Tool".


(Note: If you create the solution using one of the "Visual C# -> Cross-Platform" templates, you will need to build the UWP project once and then clean it. After that you can continue from step 3.)




## Results

Visual Studio displays an error dialog:

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




## Expected Results

No error dialog.

I suspect the XamlC target is not meant to interfere with how the UWP project treats its _own_ XAML files, but instead only how the build process treats _Xamarin.Forms_ XAML pages?

In any case, I would say it shouldn't cause the "Run Custom Tool" command to fail for XAML files in the UWP project.




## "Partial Workaround"

1. Remove or comment out "XamlC;" from the `<CompileDependsOn>` element in the Xamarin.Forms.targets file [1], at line 16.

> [1] $(UserProfile)\.nuget\packages\Xamarin.Forms\2.1.0.6529\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets

2. Close and reopen the solution.

After these steps the "Run Custom Tool" command will no longer produce an error.




## Additional version info (brief)

Microsoft Visual Studio Professional 2015
Version 14.0.24720.00 Update 1

Windows 10 (64-bit)
Comment 3 Chris King 2016-04-14 17:26:35 UTC
Tried reproducing it. Looks fixed.

Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-14 19:11:59 UTC
## Verification status: verified fixed on Xamarin.Forms 2.2.0.5-pre2

GOOD: Xamarin.Forms 2.2.0.5-pre2
BAD:  Xamarin.Forms 2.1.0.6529

There were several changes in `Xamarin.Forms.Build.Tasks.dll` between those 2 versions. One of those changes apparently corrects this problem. (As one additional "hacky" verification, I was able to stop the problem in 2.1.0.6529 by replacing the `Xamarin.Forms.Build.Tasks.dll` file with the corresponding file from 2.2.0.5-pre2.)