Skip to content

Handling of startup hooks in linked applications #36526

Closed

Description

@vitek-karas

The startup hook feature is inherently linker unfriendly as it loads "random" assemblies and executes code in them. As such using it on applications which are trimmed by the linker is problematic and likely to break the app or the startup hook.

This issue is to determine if there's some technical solution we can implement to make this more predictable experience.

Linker will also mark the implementation code in CoreLib as unfriendly and this will need some changes (either suppression, feature switch or something else):

private static void CallStartupHook(StartupHookNameOrPath startupHook)

Potentially related feature might be marking assemblies which were linked per dotnet/linker#1194 as that could be used to detect linked apps by the customers.

Activity

  1. vitek-karas commented on May 15, 2020

    @vitek-karas
    MemberAuthor
  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 8, 2020
  3. added this to the 5.0.0 milestone on Jul 8, 2020
  4. eerhardt commented on Jul 22, 2020

    @eerhardt
    Member

    Moving to 6.0 since this scenario isn't needed for Blazor WASM apps.

  5. modified the milestones: 5.0.0, 6.0.0 on Jul 22, 2020
  6. vitek-karas commented on Oct 19, 2020

    @vitek-karas
    MemberAuthor

    I think startup hooks should be behind a feature switch as that is the only reliable solution to this - trimmed apps can't use startup hooks to their full potential.

    For some specific cases, where the startup hook assembly is known before hand (for example since it's part of the target environment - hosting provider telemetry, ...) it might be possible to make this work by:

    • Enable the feature switch
    • Add the startup hook assembly to the input to the linker so that it can keep around its dependencies
    • Suppress the linker warnings generated by the startup hook implementation
      That said we should not proactively implement a solution until we know of at least a couple use cases so that we have some real-world usage to test the design on.
  7. ghost locked as resolved and limited conversation to collaborators on Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions