You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Reflection;usingSystem.Runtime.InteropServices;// Get the array of runtime assemblies.// This will allow us to at least inspect types depending only on BCL.varruntimeAssemblies=Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(),"*.dll");// Create the list of assembly paths consisting of runtime assemblies and the input file.conststring?metadataFile=@"C:\Windows\System32\WinMetadata\Windows.Foundation.winmd";List<string>paths=new(runtimeAssemblies.Append(metadataFile));// Create MetadataLoadContext that can resolve assemblies using the created list.PathAssemblyResolverresolver=new(paths);MetadataLoadContextmlc=new(resolver);foreach(vartypeinmlc.LoadFromAssemblyPath(metadataFile).GetTypes()){var_=type.IsValueType;}
AssemblyReferenceHandle is "virtual" (Treatment is TypeRefTreatment.SystemDelegate, that gives AssemblyReferenceHandle.VirtualIndex.System_Runtime(0) RowID), but EcmaResolver is not prepared to handle that properly, instead, it tries to use AssemblyRefTable (MetadataTable), which obviously fails.
.NET SDK 6.0.100-rc.2.21428.3, Windows 10.0.22000 x64
Regression?
Unlikely, but I don't know for sure.
Other information
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Reflection.TypeLoading.Ecma.MetadataTable`2.GetOrAdd(EntityHandle handle, C context, Func`3 factory)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.ResolveToAssemblyOrExceptionAssembly(AssemblyReferenceHandle handle, EcmaModule module)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.TryResolveAssembly(AssemblyReferenceHandle handle, EcmaModule module, Exception& e)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.ResolveAssembly(AssemblyReferenceHandle handle, EcmaModule module)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.ComputeTypeRefResolution(TypeReferenceHandle handle, EcmaModule module)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.<>c.<.cctor>b__15_1(EntityHandle h, EcmaModule m)
at System.Reflection.TypeLoading.Ecma.MetadataTable`2.GetOrAdd(EntityHandle handle, C context, Func`3 factory)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.ResolveTypeRef(TypeReferenceHandle handle, EcmaModule module)
at System.Reflection.TypeLoading.Ecma.EcmaResolver.ResolveTypeDefRefOrSpec(EntityHandle handle, EcmaModule module, TypeContext& typeContext)
at System.Reflection.TypeLoading.Ecma.EcmaDefinitionType.SpecializeBaseType(RoType[] instantiation)
at System.Reflection.TypeLoading.RoDefinitionType.ComputeBaseTypeWithoutDesktopQuirk()
at System.Reflection.TypeLoading.RoType.ComputeBaseType()
at System.Reflection.TypeLoading.RoType.GetRoBaseType()
at System.Reflection.TypeLoading.RoType.get_BaseType()
at System.Reflection.TypeLoading.RoType.ComputeBaseTypeClassification()
at System.Reflection.TypeLoading.RoType.GetBaseTypeClassification()
at System.Reflection.TypeLoading.RoType.IsValueTypeImpl()
at System.Type.get_IsValueType()
The text was updated successfully, but these errors were encountered:
Description
AssemblyReferenceHandle
is "virtual" (Treatment
isTypeRefTreatment.SystemDelegate
, that givesAssemblyReferenceHandle.VirtualIndex.System_Runtime
(0) RowID), butEcmaResolver
is not prepared to handle that properly, instead, it tries to useAssemblyRefTable
(MetadataTable
), which obviously fails.A bit of context:
runtime/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Ecma/EcmaResolver.cs
Lines 75 to 78 in cffaa78
runtime/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Ecma/MetadataTable.cs
Lines 29 to 36 in cffaa78
Configuration
.NET SDK 6.0.100-rc.2.21428.3, Windows 10.0.22000 x64
Regression?
Unlikely, but I don't know for sure.
Other information
The text was updated successfully, but these errors were encountered: