-
Notifications
You must be signed in to change notification settings - Fork 214
Description
I am trying to build Asp.Net core Web Api application as Native-AOT and facing below exception.
EXEC : error : Unable to cast object of type 'Internal.TypeSystem.ArrayType' to type 'Internal.TypeSystem.Ecma.EcmaType'.
System.InvalidCastException: Unable to cast object of type 'Internal.TypeSystem.ArrayType' to type 'Internal.TypeSystem.Ecma.EcmaType'.
at ILCompiler.Dataflow.DynamicallyAccessedMembersBinder.GetPropertiesOnTypeHierarchy(TypeDesc type, Func2 filter, BindingFlags bindingFlags)+MoveNext() at ILCompiler.Dataflow.DynamicallyAccessedMembersBinder.GetDynamicallyAccessedMembers(TypeDesc typeDefinition, DynamicallyAccessedMemberTypes memberTypes)+MoveNext() at ILCompiler.Dataflow.ReflectionMethodBodyScanner.MarkTypeForDynamicallyAccessedMembers(ReflectionPatternContext& reflectionContext, TypeDesc typeDefinition, DynamicallyAccessedMemberTypes requiredMemberTypes) at ILCompiler.Dataflow.ReflectionMethodBodyScanner.RequireDynamicallyAccessedMembers(ReflectionPatternContext& reflectionContext, DynamicallyAccessedMemberTypes requiredMemberTypes, ValueNode value, Origin targetContext) at ILCompiler.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(NodeFactory factory, FlowAnnotations flowAnnotations, Logger logger, GenericParameterDesc genericParameter, TypeDesc genericArgument, TypeSystemEntity source) at ILCompiler.UsageBasedMetadataManager.GetFlowDependenciesForInstantiation(DependencyList& dependencies, NodeFactory factory, Instantiation instantiation, Instantiation typicalInstantiation, TypeSystemEntity source) at ILCompiler.UsageBasedMetadataManager.GetDependenciesForGenericDictionary(DependencyList& dependencies, NodeFactory factory, MethodDesc method) at ILCompiler.DependencyAnalysis.MethodGenericDictionaryNode.ComputeNonRelocationBasedDependencies(NodeFactory factory) at ILCompiler.DependencyAnalysis.ObjectNode.GetStaticDependencies(NodeFactory factory) at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.GetStaticDependenciesImpl(DependencyNodeCore1 node) at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.ProcessMarkStack()
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan()
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
Below is my code-
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}