Bug 41841 - Global Style will let application throw exception when Release UWP and run it (native build)
Summary: Global Style will let application throw exception when Release UWP and run it...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: UWP
Assignee: Paul DiPietro [MSFT]
Depends on:
Reported: 2016-06-15 09:45 UTC by Mike
Modified: 2017-06-15 16:24 UTC (History)
3 users (show)

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

Sample file (123.33 KB, application/x-zip-compressed)
2016-06-16 07:18 UTC, Mike

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:

Description Mike 2016-06-15 09:45:57 UTC
Sometime we need some global style like:

      <Style x:Key="CustomBackground" TargetType="Grid">
        <Setter Property="BackgroundColor" Value="Black"/>
        <Setter Property="Opacity" Value="0.5"/>

And then we could use {Binding StaticResource CustomBackground} to use it in XAML. All fine when Debug(or remove native build option, in the default it enabled only when Release)

But when we need to Release the application(select native build in UWP, this is a default option), This will cause a exception:

引发的异常:“System.InvalidOperationException”(位于 System.Linq.dll 中)
“System.InvalidOperationException”类型的异常在 System.Linq.dll 中发生,但未在用户代码中进行处理
其他信息: NoMatch

The most weird thing is it will throw exception on:

MainPage = new ContentPage {};  // This place in App class
Comment 1 Mike 2016-06-15 17:29:51 UTC
Currently I doubt .net core beta version cause this problem.  I'll continue test again after June 27th when the .Net core release.

Comment 2 Mike 2016-06-16 07:17:34 UTC
I already try "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.0"

But still throw exception when Release and run the project.

I upload a sample file for you guys test.(Debug no problem)
Comment 3 Mike 2016-06-16 07:18:39 UTC
Created attachment 16354 [details]
Sample file
Comment 4 Mike 2017-01-07 07:20:45 UTC
I guess maybe because I open compile xaml namespace mode when release. use this:

[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
Comment 5 Paul DiPietro [MSFT] 2017-03-02 15:28:24 UTC
To follow up, is this still an issue for you then with the latest stable/pre, or does XamlC resolve it? If it's still giving you trouble, putting a reproduction together would be helpful for taking a look at.
Comment 6 Paul DiPietro [MSFT] 2017-06-15 16:24:33 UTC
Closing this due to no response. Please reopen and attach a minimized reproduction project if the issue still exists as of the latest prerelease or nightly build.