Skip to content

ILC: FileNotFoundException for base type from unresolved assembly #103843

@sbomer

Description

@sbomer

Discovered while investigating a similar linker failure in #93797. Repro:

app.csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <PublishAot>true</PublishAot>
        <WarningsAsErrors>false</WarningsAsErrors>
        <NoWarn>NU1605;NU1603;NU1701</NoWarn>
    </PropertyGroup>

    <ItemGroup>
        <TrimmerRootAssembly Include="Syncfusion.Maui.Gauges" />
        <PackageReference Include="Syncfusion.Maui.Gauges" Version="20.4.40" />
    </ItemGroup>
</Project>

dotnet publish

Stack trace from the output:

EXEC : error : Failed to load assembly 'Microsoft.Maui.Controls' [/home/svbomer/src/test-apps/crashes/crashes.csproj]
         Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'Microsoft.Maui.Controls'
            at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID, String) + 0x30
            at Internal.TypeSystem.ResolutionFailure.Throw() + 0xfd
            at Internal.TypeSystem.Ecma.EcmaType.InitializeBaseType() + 0x1da
            at ILCompiler.DependencyAnalysis.TypeMetadataNode.GetStaticDependencies(NodeFactory) + 0x186
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1) + 0x3f
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1) + 0x33
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() + 0xff
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() + 0x4f
            at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() + 0x19
            at ILCompiler.Program.<Run>g__RunScanner|4_0(Program.<>c__DisplayClass4_0&) + 0x1fa
            at ILCompiler.Program.Run() + 0x29cc
            at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass240_0.<.ctor>b__0(ParseResult result) + 0x35a

#103844 adds a test for this (disabled for Native AOT).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions