Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMetadataException with .NET Native on 19041 #2545

Closed
Sergio0694 opened this issue May 25, 2020 · 32 comments
Closed

MissingMetadataException with .NET Native on 19041 #2545

Sergio0694 opened this issue May 25, 2020 · 32 comments
Labels
area-External Not owned by the WinUI team, not actionable in this repository. no-issue-activity

Comments

@Sergio0694
Copy link
Member

Sergio0694 commented May 25, 2020

Describe the bug

I've recently updated to Windows 10 19041.264, and apparently many .NET Native builds are just flat out broken for me. This includes both the Windows Community Toolkit Sample app (straight from master, cc. @michael-hawker) as well as my own app Legere (cc. @LanceMcCarthy, since you helped me pinpoint the previous issue in #1286). Some info I managed to gather:

  • The .NET Native runs fine, but the app crashes at startup.
  • I can't repro this with a blank UWP app
  • I can repro this both in the Windows Community Toolkit Sample App and in my own app, but the crashes happen with two different types. Specifically, Windows.Foundation.IReference<double> in the sample app, and SCG.IList<WCT.Uwp.UI.Media.Effects.IPipelineEffect> in my app.
  • My app has this crash when I build it with .NET Native on my PC, but if i create a Store package without .NET Native and let the Store build it with .NET Native remotely, then the app package I install from the Store works just fine. I suspect this might be because the Store is using some VMs that have a previous Windows 10 build than 19041? 🤷‍♂️

Important question

Related to this last point, assuming this is the case, I fear that if the W10 VM the Store uses to build the apps with .NET Native gets updated to one with W10 19041, the Store could just recompile the app again (it does so occasionally) and just push that update to all my users, which would then completely trash my app, since on my device it just crashes at startup with the .NET Native build done on W10 19041. Is this fear justified? Is there anything I can do regarding this?

cc. @MichalStrehovsky and @MattWhilden as the two .NET Native experts here 😄

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Clone the Windows Community Toolkit repo (here), switch to master (ae4000bcc6cd8eb235b9915a811bd5ea1097169a at the moment).
  2. Run the Sample App in Debug x64, observe it works just fine
  3. Right click on the Sample App project > Build > tick ".NET Native toolchain"
  4. Rebuild and run
  5. Observe the crash with that metadata exception (and others as well if you click continue)

Expected behavior

The app should work just fine.

Screenshots

image

Version Info

NuGet package version:

Microsoft.UI.Xaml 2.4.2

Windows 10 version Saw the problem?
Insider Build (19041.264) 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

Just as a test, I tried to checkout my app to a commit from 4+ months ago. I got the same exact crash in the same exact spot, just with a different type (I wasn't using the .Media package from the toolkit at that time since it didn't exist yet). When I was on 18363, I could build and run the app just fine with .NET Native, except for that other issue mentioned already in #1286.

Note that the current version of my app targets the 19041 SDK, while the version from 4+ months ago targets the 18362 SDK. Both crash with the same exact error, as mentioned above.

@LanceMcCarthy since you're already familiar with my repo (Legere) as you helped me debug that issue the other time, if you're on 19041 too would you mind if I gave you access to it again to try to see if you can repro the same crash on your end as well?
Just to double check and hopefully gather some more info.

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label May 25, 2020
@Sergio0694 Sergio0694 changed the title MissingMetadataException with .NET Native builds on W10 19041 MissingMetadataException with .NET Native on 19041 May 25, 2020
@MichalStrehovsky
Copy link
Member

For .NET Native issues I suggest reaching out to dotnetnative at microsoft dot com. This is possibly an issue with the Windows SDK installation, but it's difficult to say.

@LanceMcCarthy
Copy link

LanceMcCarthy commented May 26, 2020

@Sergio0694 I'll spin up a repro today and report it internally to MSFT SDK team.

My first suspicion is that there is some code being stripped out while compiling, this is the usual reason for MissingMetadataException.

In the meantime, you can avoid this by adding those assemblies to the Runtime Directives list in the Properties/default file. See the example at the top here https://docs.microsoft.com/en-us/dotnet/framework/net-native/runtime-directives-rd-xml-configuration-file-reference

@Sergio0694
Copy link
Member Author

Sergio0694 commented May 26, 2020

@LanceMcCarthy That's awesome, thanks! I have to say I did try to add some .rd.xml directives for those missing types, with no luck so far though. I'm sure others with more experience than me might have better results though, I'll try following that link you posted and trying again! 😄

Also I've added you as a collaborator to Legere again in case you need to repro the issue on that solution too. I just find it so weird that the .NET Native build from the Store works fine 🤔

@MichalStrehovsky Sure, I'll forward this issue and all the details to that address too!
I just wanted to also open a public issue here on GitHub so that other UWP developers stumbling on this as well might see this, instead of having to start investigating the whole thing from scratch.

EDIT: tried in Legere, no luck so far. I'm seeing this type which causes the exception:

System.C.G.IList`1<Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces.IPipelineEffect>

I've tried with the following directives in my .rd.xml file:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>

    <!--
      An Assembly element with Name="*Application*" applies to all assemblies in
      the application package. The asterisks are not wildcards.
    -->
    <Assembly Name="*Application*" Dynamic="Required All" />

    <!-- System.Collections.Generic.IList`1<Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces.IPipelineEffect> -->
    <Namespace Name="System.Collections.Generic" >
      <TypeInstantiation Name="IList"
                         Arguments="Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces.IPipelineEffect"
                         Serialize="Required All"
                         Dynamic="Required All"/>
    </Namespace>
  </Application>

  <!-- Microsoft.Toolkit.Uwp.UI.Media package -->
  <Library Name="Microsoft.Toolkit.Uwp.UI.Media">
    <Namespace Name="Microsoft.Toolkit.Uwp.UI.Media"
               Serialize="Required All"
               Dynamic="Required All"/>
    <Namespace Name="Microsoft.Toolkit.Uwp.UI.Media.Effects"
               Serialize="Required All"
               Dynamic="Required All"/>
    <Namespace Name="Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces"
               Serialize="Required All"
               Dynamic="Required All"/>
  </Library>
</Directives>

But I'm still getting the same error 🤔
I'm by no means an expert on compiler directives, so I might very well be missing something here.

@LanceMcCarthy
Copy link

@Sergio0694 I would try setting the type to the exact one that code uses. Maybe somethign like this:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Namespace Name="Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces" Serialize="Required Public" />
    
    <TypeInstantiation Name="SCG.IList" Arguments="WCT.Uwp.UI.Media.Effects.IPipelineEffect" Activate="Required Public" />

  </Application>
</Directives>

so that we don't clog up this thread, lets move the debugging investigation to a Legere Issue and then come back here with the final solution

@LanceMcCarthy
Copy link

Pro Tip for any future visitors, use the MissingMetadataException Troubleshooter to build the Default.rd.xaml file for you!

@Sergio0694
Copy link
Member Author

Sergio0694 commented May 26, 2020

Wait WHAT! Where has that been this whole time? 😱
And why is it not listed like everywhere in the UWP docs?

Thank you so much! I'll share those links in the Discord server as well 👍

@MichalStrehovsky
Copy link
Member

And why is it not listed like everywhere in the UWP docs?

It's supposed to be linked from the relevant exception messages. Not sure why there's no message on your screenshot - could be yet another bug. It definitely was part of the message when I originally added it for .NET Native 1.0. Those pages represent all the JavaScript I wrote in the past 10 years.

The problem with Windows.Foundation.IReference<double> is that this is a projected type (maps to Nullable<double> - that's why I think this is an SDK bug somewhere. I don't expect RD.XML to help with that one and I'm unclear how we can even end up in that situation (I don't know much about WinRT interop).

@ranjeshj ranjeshj added area-External Not owned by the WinUI team, not actionable in this repository. and removed needs-triage Issue needs to be triaged by the area owners labels May 27, 2020
@Sergio0694
Copy link
Member Author

Possibly related to this, I have another app that is exhibiting a similar behavior:

  • Works perfectly fine in Debug
  • Crashes at startup with .NET Native only on Windows 10 19041

image

Together with Legere and the Windows Community Toolkit ( @michael-hawker is that still the case), this seems to be the 3rd app that just has weird issues/crashes with .NET Native on W10 19041. What's more, with this one the crash is there even with the package downloaded from the Store, but again only on Windows 10 19041. Installing and running the app on a PC with W10 18362/18363 works fine.

I was wondering whether there could be some underlying issue of some sort with W10 19041 related to this, or just something in common between all these various issues on 19041? And most importantly, does anyone have any idea for a workaround? I'm at a loss here, both my apps are just a no-go on W10 19041 at the moment and I have no idea why that is or how to solve this 😟

@MichalStrehovsky @MattWhilden This is not really ILC repro material as the .NET Native compiler itself is working fine and the app is built/run correctly, so I'm not sure if there's any repro that I could prepare for you guys that could help? In general, who should I talk to for issues such as these?

@michael-hawker
Copy link
Collaborator

🦙 FYI @tommcdon

@MattWhilden
Copy link

@Sergio0694 ILCRepros are still quite helpful for app crashes. Being able to rebuild the package and run it lets us help test theories and fixes for runtime issues. 😊

@Sergio0694
Copy link
Member Author

Sergio0694 commented Jun 1, 2020

@MattWhilden Ah, awesome then! 😄
Will prepare one (or two) and send them to you guys then ([email protected]).

EDIT: email sent! 🚀

@Sergio0694
Copy link
Member Author

Hey @MichalStrehovsky and @tommcdon, I have some more info on the repro I sent you guys last week. In particular, I was having a ton of crashes with my second app (the one with that exception about IReference<double> missing, and it took a while but I eventually found a (very ugly) workaround.

I have a separate project which contains two self-contained controls I wrote for my app, which I just reference from my main app, adding the resource dictionary definition in App.xaml to load the styles from the library, and then using controls from there as usual. This worked 100% fine in Debug, but crashed with .NET Native. Turns out literally just referencing that package causes this crash, even if I don't actually use any code/controls from there at all.

The solution I found was to remove the reference to that project and manually link all the files from that project directly into my main application. Despite the code being exactly the same, this worked just fine with .NET Native. I guess there's some issue loading metadata from secondary projects? 🤷‍♂️

That said, I'm still left with quite a few (weird) issues, specifically:

  • I can build and run the app in Debug with .NET Native just fine
  • Release still crashes at startup, this time with some weird exception from KernelBase.dll or something. This is the same situation I get from my other app Legere: both run fine in Debug, with and without .NET Native, but just fall apart in Release mode.
  • If I build a Store package (which is built in Release but without .NET Native), and then install the app from the Store (which is built with .NET Native remotely), then that package works fine.
  • There are some crashes I'm seeing in the Store version though that I can't investigate. As in:
    • ✅ Running the app from the Store, I can repro the crash
    • ❌ Debug doesn't exhibit the crash
    • ❌ Debug with .NET Native doesn't exhibit the crash
    • ❌ Release just falls apart at startup due to the other issue mentioned above

I should also note that one of my apps targets the 19041 SDK, the other targets the 18362 SDK. But they're both showing this weird behavior where they just explode in a local Release build, but work (mostly) fine when downloaded from the Store. Also there are occasional crashes as mentioned before, that only happen with the Store package and that I can't investigate at all right now.

This whole situation is extremely unfortunate, and I hear I'm not the only developer struggling with .NET Native at the moment. Both me and the other devs I talk to are on Windows 10 19041, so somehow it looks like there's something up with .NET Native on this version of Windows? 🤔

Also I'm lost as to how to investigate those crashes I'm seeing with the Store version, but not in Debug with .NET Native. As long as .NET Native is enabled, shouldn't crashes due to it happen both in Debug and Release? Especially because debugging Release build is not ideal anyway.

Any help here would be much appreciated! 😊

Also please let me know if I should forward this to anyone else, from the SDK team or something.
I just pinged you guys from .NET Native to share the repro and because I've talked to you all in the past already regarding somewhat similar issues, but I'm wondering whether there are other official channels I'm supposed to forward this too as well? Thanks again!

@Sergio0694
Copy link
Member Author

@LanceMcCarthy Just wondering, when/if you had some time to waste, would you be interesting in checking out this second app that has all these other weird issues I listed? I'd be happy to give you access to this repo as well, and if we could confirm that (at least some of) these issues are in fact due to some SDK glitches as @MichalStrehovsky suggested, maybe you could report them as well through your contacts with the SDK team? I personally have no connections in that area 😕

@LanceMcCarthy
Copy link

I plan on whittling it down to a bare minimum repro. I haven't had a chance to start it yet because I'm in the middle of recording a video training series with a tight deadline.

Is it possible to have just two projects in a solution. One with the control/component, then the other consuming that control/component and causes the crash?

With that, I can send it right to the team (small repro get the fastest attention because it only takes a minute to spin it up)

@Sergio0694
Copy link
Member Author

@LanceMcCarthy Oh no, absolutely, my ping was just supposed to be an FYI, it really wasn't meant to rush you or anything! Was just curious to know whether this second issue would be something you might be interested in taking a look into and investigating too 😊

I'll get to work on a minimal solution with just those two projects, thanks again! 🎉

@Sergio0694
Copy link
Member Author

Sergio0694 commented Jun 10, 2020

@LanceMcCarthy Again just FYI (not rushing), I made the repro like you mentioned, with just:

  • UWP app project
  • UWP class library with the controls

You can find the repro in the repro/sdk-crash-release branch. The app in master has exactly the same issue, the only difference is in that branch I've removed all but two projects, and removed unnecessary code (eg. all the MVVM stuff, all the backend code, additional features, etc.).

As mentioned before:

  • ✅ Debug works fine
  • ❌ Debug .NET Native crashes at startup
  • ❌ Release .NET Native crashes at startup

Bonus weird issue: right-clicking the text box in the app to open the context menu will crash the app only with a package installed from the Store (!). Doing exactly the same with a Debug .NET Native build works just fine instead. Really no idea of why that's happening only from the Store 🤷‍♂️

This is the crash I'm seeing in AppCenter for this case:

image

Though as mentioned, I can't repro that locally even with .NET Native. I don't know why, but there just seem to be a whole lot of different weird issues going on all at once with this app 🤣

Thanks again, I really appreciate the help!

@LanceMcCarthy
Copy link

@Sergio0694 Thanks, I've cloned it and am working on preparing the repro now. I'll open an issue in the repo for any private-project related stuff.

To comment on to your statement about how it work with a Debug .NET Native build, that's still fundamentally different than a Release build. Do a release build and side-load/appinstaller load, I think the same crash should occur.

@LanceMcCarthy
Copy link

LanceMcCarthy commented Jun 10, 2020

@michael-hawker I just reproed and reviewed the output, it's definitely happening in Windows,UI.xaml

Release build, signed msix, sideload-installed (Store ingestion doesn't appear to be related)

Event Viewer

Faulting application name: REDACTED.Uwp.exe, version: 1.0.0.0, time stamp: 0x5ee155af
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.18362.815, time stamp: 0x9fa806f2
Exception code: 0xc000027b
Fault offset: 0x0000000000713530
Faulting process id: 0x61ec
Faulting application start time: 0x01d63f71d635f57a
Faulting application path: C:\Program Files\WindowsApps\REDACTED_1.610.1.0_x64__REDACTED\REDACTED.Uwp.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 22e98e81-c491-492c-9b5c-e0806edd6751
Faulting package full name: 77cee5e8-8481-4e69-92bc-31cfb2a6bc2b_1.610.1.0_x64__REDACTED
Faulting package-relative application ID: App

What's strange (or maybe not), the version of Windows.UI.Xaml.dll is 18362 even though the following packages are installed:

    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
      <Version>6.2.10</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
      <Version>6.1.0-rc1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Media">
      <Version>6.1.0-preview1.2</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.UI.Xaml">
      <Version>2.4.2</Version>
    </PackageReference>

@Sergio0694 Can you confirm that all of the views have, definitely, replaced the UI components with Microsoft.UI.Xaml and not are still falling back to Windows.UI.Xaml?

Cannot apply a style targeting Windows.UI.Xaml.ContentPresenter with Windows.UI.Xaml.ContentPresenter is suspicious, as if they're different types.

@Sergio0694
Copy link
Member Author

Sergio0694 commented Jun 10, 2020

@LanceMcCarthy Thank you so much for looking into this!

I'd say the crash coming from WUX is not unsurprising, I'm using Microsoft.UI.Xaml only in a couple places, specifically for the ItemsRepeater and TeachingTip controls, and for a few reveal brushes.
The rest of the app is based on Windows.UI.Xaml. Also note that WinUI 2.x isn't a 1:1 replacement for WUX, so even if I wanted I wouldn't be able to just replace all the UI components in my app with controls from WinUI, as there's a lot of controls that aren't there at all.

Side question: any clue as to how it's possible that the Release build just crashes at startup, but the one downloaded from the Store works fine instead? I find that very weird 🤔

Side question n. 2: is that style exception you mentioned the one that happens when trying to open the context menu in the IDE? If that's the one, then yeah that's very weird that it's as if it was trying to load the style for a different control apparently, really not sure where that's coming from.
Especially because again, that part works perfectly fine in Debug instead.

EDIT: just posting here a recap of the various issues I've noticed in the app, as a reference:

  • 💥 Having a separate UWP class library with the controls crashes the app with .NET Native (both Debug and Release). Removing the reference to the class library and linking those same files directly in the app fixes the crash (this was that IReference<double> missing metadata error that @MichalStrehovsky commented on)
  • 💥 Even without the class library, the app just crashes at startup in Release.
  • 💥 Opening the context menu in the IDE crashes in Release.
  • ⁉ While a local Release build crashes at startup, a Release build downloaded from the Store works fine. It still exhibit the crash in the context menu in the IDE, but the rest of the app works.

@LanceMcCarthy
Copy link

I'm not seeing a startup crash, just the right-click crash. I'm compiling with 19041, but installing on an 18363 machine (which explains why the C:\Windows\System32\Windows.UI.Xaml.dll is v18362 in the crash report).

I don't have 19041 installed, thanks to the Surface update blocks, so I can't much help testing there.

@Sergio0694
Copy link
Member Author

Sergio0694 commented Jun 10, 2020

Mmh I think Windows 10 19041 might have something to do about this then.

I just tried to run the app in Release (with the merged resource change you mentioned), and the app is once again just crashing badly right at startup, I'm seeing this (not very useful) exception:

image

Tried in Debug with .NET Native, and I'm once again back at square one with a startup crash 😥

image

It looks like .NET Native on W10 19041 just doesn't like the separate class library with the controls. Which doesn't really make sense, like, why does the installed W10 version even matter? 🤔

EDIT: also spent 30 minutes loading the symbols for Windows.UI.Xaml.Controls from the Microsoft symbols server, but didn't get any useful info, apparently those types are not in the symbol files. Not sure how that even works exactly, but VS just left it at that without much other info.

@stevenbrix
Copy link
Contributor

@Sergio0694 do you see any spew in the Debug output window that might be helpful?

It looks like a style target type is incorrect (ItemsPresenter vs ContentPresenter) I don't have any ideas why that would be yet.

@LanceMcCarthy
Copy link

This is probably the culprit

            <ItemsControl
                ItemsSource="{x:Bind constants:CodeSnippets.All}"
                ItemTemplate="{x:Bind CodeSnippetTemplate}">
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="ItemsPresenter">
                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>

@Sergio0694
Copy link
Member Author

@LanceMcCarthy Can confirm that switching that ItemsPresenter to ContentPresenter solves the issue! I've uploaded a build to the Store and installed that back, the context menu works great! 🎉

So for now there remains the other various startup crashes on 19401.
I also can confirm that fixing the style here didn't solve those startup crashes.

Still, that's progress though, thanks! 😄

@IsmailHassani
Copy link

IsmailHassani commented Aug 1, 2020

This is weird, i have almost exact same exceptions in my framework project.
I-Synergy. Framework (features/dev branch)

I'm pulling my hair out for a week. Tried even to disect the .dmp file without luck.
I have a framework project with an UWP sample which crashes instantly on startup. The exceptions i get are:

  • MissingMetaDataException: Windows.Foundation.IReference{double}
  • Styles imported from I-Synergy.Framework.Windows: 'I-Synergy.Framework.Windows/Controls/HeaderedTextBlock/
    HeaderedTextBlock.xaml is not a valid absolute URI.'.
  • For 3 styles : Cannot locate resource from 'ms-appx:///ISynergy.Framework.Windows/Controls/BladeView/BladeView.xaml'. [Line: 11 Position: 37] which is strange because the other ones in the App.xaml are the same. I had to uncomment the lines to be able to get a step further.

Also a strange thing: Commit with tag 2020.1174.1.0 was build successfully several weeks ago, but now i have no way to debug it in native mode.

@IsmailHassani
Copy link

After investigating more this weekend i tried to push my updates to the Azure build pipeline.
If build 2020.1174.1 was build fine previously, and now it doesn't, maybe this is a local issue.
Strangely, i've got it right. The build has succeeded and the application is runnable just fine.
So why i'm getting these exceptions when i build a native release locally?

@ricklee7679
Copy link

I came across this open issue when searching - MissingMetaDataException: Windows.Foundation.IReference. I got that mentioned exception when debugging a UWP app that uses a in-house UWP class library which defines some custom user controls. It happens only when "Compile with .Net Native tool chain" is checked in the UWP app's Build properties, under debug mode. I later found adding that class library reference to UWP app can cause the exception, when UWP app does not even use anything in the class library.
Here is how this issue can be reproduced by adding a user control class library to the Microsoft's Xaml control gallery app -

  1. Git clone the Microsoft Gallery app
    git clone https://github.com/microsoft/Xaml-Controls-Gallery.git

  2. Open the XamlControlsGallery.sln solution file in Visual Studio (mine is Enterprise 2019, but I think other versions should do it too)

  3. Build and Run (hit [F5]) the project with "Debug | x64" build type, and you should see the app runs OK.

  4. Stop debugging the app, now add a new UWP class library to the solution, name the project whatever you like.

  5. Add a user control (or templated control) in the UWP class library by right-clicking on its project, then "Add" -> "New Item" -> enter "User Control" to filter and then add a User Control, accepting everything default.

  6. You may adjust the target Windows version and min version in the UWP class library's project properties to make them in line with the gallery app's. One Nuget package may have a different version between the two is "Microsoft.NETCore.UniversalWindowsPlatform", in that case, use Nuget package manager to update class library's and bring them in sync, like -
    image

  7. Add the class library project as a reference to the gallery app project and then debug run the gallery app, the exception happens -
    image

  8. Uncheck "Compile with .Net Native tool chain" in gallery app's project Build settings, save and then debug run again, the app runs fine when the setting is OFF.
    image

The same exception happens when targeting a different platform (x86) in debug mode, or substituting the class library with a "Windows Runtime Component (Universal Windows)" project in hosting the user control.
Please let me know if have any inputs or you see this issue is better reported to another place. Thanks!

@michailowski
Copy link

Greetings!

When trying to compile my project with the .NET Native tool chain I got a similar exception:
MissingMetadataException: Windows.Foundation.IReference'1<Double>.

I also agree that adding a reference to a class library that contains user controls causes this exception. I join the question from @ricklee7679. Does anyone else have any ideas on how to fix this? Any help would be appreciated!

@tommcdon
Copy link
Member

tommcdon commented Jan 3, 2022

Greetings!

When trying to compile my project with the .NET Native tool chain I got a similar exception: MissingMetadataException: Windows.Foundation.IReference'1<Double>.

I also agree that adding a reference to a class library that contains user controls causes this exception. I join the question from @ricklee7679. Does anyone else have any ideas on how to fix this? Any help would be appreciated!

Please try setting EnableTypeInfoReflection to false in each project that uses XAML:

<PropertyGroup>
    <EnableTypeInfoReflection>false</EnableTypeInfoReflection>
</PropertyGroup>

@michailowski
Copy link

Thanks @tommcdon, that solves the problem, but am I correct in assuming that this is a temporary solution?

@omikhailov
Copy link

Unfortunatelly, the workaround proposed by @tommcdon does not solve the issue in my case (CommunityToolkit/WindowsCommunityToolkit#4254). Perhaps, the case when WinUI, WCT or other library with controls is referenced in more than one project is more complicated.

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-External Not owned by the WinUI team, not actionable in this repository. no-issue-activity
Projects
None yet
Development

No branches or pull requests