Closed
Description
In certain custom hosting scenarios, it is desirable to prime the runtime by running a dummy application with a startup hook and then give the host the ability to change the application being run by altering its entry assembly and probing paths.
The way the custom host can achieve this is by:
- Update the HOST_RUNTIME_CONTRACT to contain the entry assembly, TPA list, and paths for native and satellite assembly probing.
- Propose a new managed API to support changing the entry assembly
- Add functions to https://github.com/dotnet/runtime/blob/main/src/native/corehost/hostpolicy/hostpolicy_context.cpp so the host can provide the runtime with this new info.
- Expand https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/hostinformation.cpp so the runtime can more easily get at the new info
- Update the runtime to use this new info instead of directly reading from properties.
- Add a check if the entry assembly changed and re-query the entry assembly and lookup paths after the startup hooks are run.
Rules of note
- We should start with only allowing System.Private.CoreLib to be loaded because once it's loaded, we cannot replace it
- The exception to the rule is the entry assembly.
- If the thread apartment state changes, the main thread needs updated. See Streamline Windows Forms application configuration and bootstrap designs#223 (comment)
- It is the responsibility of the custom host to check if the new runtime config is compatible via
hostfxr_initialize_for_runtime_config
Success_HostAlreadyInitialized
: compatibleSuccess_DifferentRuntimeProperties
: technically compatible, but may impact runtime behavior. Not advised to useCoreHostIncompatibleConfig
: incompatible
Considerations
- For inspiration of the
HOST_RUNTIME_CONTRACT
structure, mono has an equivalent-ish implementation.
Metadata
Metadata
Assignees
Type
Projects
Status
No status