-
Notifications
You must be signed in to change notification settings - Fork 692
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
Comments
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. |
@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 |
@LanceMcCarthy That's awesome, thanks! I have to say I did try to add some 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! EDIT: tried in Legere, no luck so far. I'm seeing this type which causes the exception:
I've tried with the following directives in my <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 🤔 |
@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 |
Pro Tip for any future visitors, use the MissingMetadataException Troubleshooter to build the Default.rd.xaml file for you! |
Wait WHAT! Where has that been this whole time? 😱 Thank you so much! I'll share those links in the Discord server as well 👍 |
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 |
Possibly related to this, I have another app that is exhibiting a similar behavior:
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? |
🦙 FYI @tommcdon |
@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. 😊 |
@MattWhilden Ah, awesome then! 😄 EDIT: email sent! 🚀 |
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 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 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 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. |
@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 😕 |
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) |
@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! 🎉 |
@LanceMcCarthy Again just FYI (not rushing), I made the repro like you mentioned, with just:
You can find the repro in the As mentioned before:
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: 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! |
@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. |
@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
What's strange (or maybe not), the version of Windows.UI.Xaml.dll is 18362 even though the following packages are installed:
@Sergio0694 Can you confirm that all of the views have, definitely, replaced the UI components with Cannot apply a style targeting Windows.UI.Xaml.ContentPresenter with Windows.UI.Xaml.ContentPresenter is suspicious, as if they're different types. |
@LanceMcCarthy Thank you so much for looking into this! I'd say the crash coming from WUX is not unsurprising, I'm using 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. EDIT: just posting here a recap of the various issues I've noticed in the app, as a reference:
|
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. |
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: Tried in Debug with .NET Native, and I'm once again back at square one with a startup crash 😥 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 |
@Sergio0694 do you see any spew in the Debug output window that might be helpful? It looks like a style target type is incorrect ( |
This is probably the culprit
|
@LanceMcCarthy Can confirm that switching that So for now there remains the other various startup crashes on 19401. Still, that's progress though, thanks! 😄 |
This is weird, i have almost exact same exceptions in my framework project. I'm pulling my hair out for a week. Tried even to disect the .dmp file without luck.
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. |
After investigating more this weekend i tried to push my updates to the Azure build pipeline. |
Greetings! When trying to compile my project with the .NET Native tool chain I got a similar exception: 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> |
Thanks @tommcdon, that solves the problem, but am I correct in assuming that this is a temporary solution? |
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. |
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. |
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 frommaster
, 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:Windows.Foundation.IReference<double>
in the sample app, andSCG.IList<WCT.Uwp.UI.Media.Effects.IPipelineEffect>
in my app.19041
? 🤷♂️Important question
cc. @MichalStrehovsky and @MattWhilden as the two .NET Native experts here 😄
Steps to reproduce the bug
Steps to reproduce the behavior:
master
(ae4000bcc6cd8eb235b9915a811bd5ea1097169a
at the moment).Expected behavior
The app should work just fine.
Screenshots
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.4.2
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 on18363
, 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.
The text was updated successfully, but these errors were encountered: