I have not changed any code. I made a minor change recently to my UWP application. I noticed that some of the packages were out of rev, so I pulled them down and started getting strange "Missing Metadata" exceptions when trying to instantiate my views (again, working great prior to this). The exception happened in this statement:
BlotterView blotterView = this.serviceProvider.GetRequiredService<BlotterView>();
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.Reflection.MissingMetadataException' in System.Private.Reflection.Core.dll
'Microsoft.Extensions.Options.IPostConfigureOptions<>' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859
So I rolled back all the package updates I made until these three packages appear to be the cause of the problem:
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
I don't know which one, exactly, is causing the problem, but with the 5.0.0 version, I get this crash.
EDIT: As nearly as I can diagnose, the issue is with the upgrade of the Microsoft.Extensions.Options 5.0 package
This error only occurs when compiling with the .NET Native toolchain
.NET: .NET Standard 2.0
Windows: Windows 10 10.0.19042
Architecture: 64
Fall back from:
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.16.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
to
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
makes it work again. Also, turning off the "Compile with Native toolset* option will make it work again.
Tagging subscribers to this area: @maryamariyan I have not changed any code. I made a minor change recently to my UWP application. I noticed that some of the packages were out of rev, so I pulled them down and started getting straing "Missing Metadata" exceptions when trying to instantiate my view models (again, working great prior to this). The exception happened in this statement: Exception thrown: 'System.Reflection.MissingMetadataException' in System.Private.Reflection.Core.dll So I rolled back all the package updates I made until these three packages appear to be the cause of the problem: I don't know which one, exactly, is causing the problem, but with the 5.0.0 version, I get this crash. .NET: .NET Standard 2.0 Fall back from: to makes it work again.
See info in area-owners.md if you want to be subscribed.
Issue Details
Description:
Description
BlotterView blotterView = this.serviceProvider.GetRequiredService<BlotterView>();
'Microsoft.Extensions.Options.IPostConfigureOptions<>' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
Configuration
Windows: Windows 10 10.0.19042
Architecture: 64Regression?
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
Author:
DRAirey1
Assignees:
-
Labels:
area-Extensions-Logging, untriaged
Milestone:
-
The problem appears to be in the new Microsoft.Extensions.Options 5.0.0 package and the .NET Native Toolchain.
Tagging subscribers to this area: @maryamariyan
See info in area-owners.md if you want to be subscribed.
Issue Details
I have not changed any code. I made a minor change recently to my UWP application. I noticed that some of the packages were out of rev, so I pulled them down and started getting strange "Missing Metadata" exceptions when trying to instantiate my views (again, working great prior to this). The exception happened in this statement:
BlotterView blotterView = this.serviceProvider.GetRequiredService<BlotterView>();
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.Reflection.MissingMetadataException' in System.Private.Reflection.Core.dll
'Microsoft.Extensions.Options.IPostConfigureOptions<>' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859
So I rolled back all the package updates I made until these three packages appear to be the cause of the problem:
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
I don't know which one, exactly, is causing the problem, but with the 5.0.0 version, I get this crash.
EDIT: As nearly as I can diagnose, the issue is with the upgrade of the Microsoft.Extensions.Options 5.0 package
This error only occurs when compiling with the .NET Native toolchain
.NET: .NET Standard 2.0
Windows: Windows 10 10.0.19042
Architecture: 64
Fall back from:
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.16.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
to
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.9" />
makes it work again. Also, turning off the "Compile with Native toolset* option will make it work again.
| Author: | DRAirey1 |
|---|---|
| Assignees: | - |
| Labels: | `area-Extensions-Options`, `untriaged` |
| Milestone: | - |
@DRAirey1 It would help if you could please share a small repro for this.
IIRC, .NET Native Toolchain assumes that all assemblies marked with AssemblyMetadataAttribute(".NETFrameworkAssembly") are compatible with .NET Native version of IL trimming. @MichalStrehovsky Could you please confirm that it is it correct?
Microsoft.Extensions.Options 3.1 is not marked as .NETFrameworkAssembly. It makes .NET Native toolchain to use conservative reflection policy that makes it work.
Microsoft.Extensions.Options 5.0 is marked as .NETFrameworkAssembly. It makes .NET Native toolchain to use more aggresive reflection policy that leads to MissingMetadataException.
IIRC, .NET Native Toolchain assumes that all assemblies marked with AssemblyMetadataAttribute(".NETFrameworkAssembly") are compatible with .NET Native version of IL trimming. @MichalStrehovsky Could you please confirm that it is it correct?
Yes, that will probably be it. .NET Native assumes that framework libraries are trimmable and ship with an embedded RD.XML that describes their dynamic behavior. It looks like we don't have test coverage for this combination anymore.
@DRAirey1 you should be able to work around by adding:
<Assembly Dynamic="Required All" Name="Microsoft.Extensions.Options"/>
Nested under the <Application> tag of your default.rd.xml file. You can find the default.rd.xml in the properties folder of your app project.
@MichalStrehovsky - Thank you. That got me past the Metadata error, but it looks like this error was just the tip of the problems with this release. Now I'm getting:
onecore\com\combase\winrt\error\restrictederror.cpp(1016)\combase.dll!00007FFC90AD0243: (caller: 00007FFC90ADE7A9) ReturnHr(1) tid(1ffc) 8007007E The specified module could not be found.
An exception of type 'System.MissingMethodException' occurred in System.Private.CoreLib.dll but was not handled in user code
Constructor on type 'Microsoft.Extensions.Logging.LoggerFactoryOptions' not found.
Again, if I fall back to
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
The error goes away.
@MichalStrehovsky - Thank you. That got me past the Metadata error, but it looks like this error was just the tip of the problems with this release. Now I'm getting:
Add a similar RD.XML entry for the Microsoft.Extensions.Logging assembly.
There's 35 of these Microsoft.Extensions assemblies because people in charge of these assemblies don't like to put more than ~20 types in a single assembly. In the worst case we'll need an entry for each.
OK. That seems to have fixed the problems I was having with the new release. Thanks for the hint. I still think you've introduced a problem, but with the hack to default.rd.xml, I'm willing to close the case if you want me to.