-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow modification of entry assembly and probing after startup hooks are run #99883
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
I do not think this bundle of features should be a special runtime mode, we should break it down into general purpose individual features that can be used independently. Also, we should prefer exposing new features via managed APIs as much as possible.
We should add a managed API to allow setting the entry assembly. It comes up every once in a while. .NET Framework allowed overriding the entry assembly via
It should be fine to load all assemblies that are tightly coupled with CoreLib too (e.g. System.Runtime.dll).
It does not need to be an error. You can reset the apartment state of the main thread: dotnet/designs#223 (comment) |
OK, then maybe we check if the entry assembly has changed and if so, have the runtime query the contract again after the startup hooks are run. That's what I meant by having some env variable to opt into the re-query. |
I do not think that this would work well. The list of app dependencies needs to be updated before the new entry assembly is loaded. Otherwise, there can be situations where the assembly fails to load due to missing dependencies. |
Unless I'm missing something, I think it's a compound operation. You have to change not only the entry assembly, but specify new deps and other probing paths before this has a chance to work. |
My understanding that the scenario we are going after is:
Does this sound right? |
My understanding is that a key part of the scenario is that the app dependencies takes precedence over what would be in the default probing for the default ALC, as overriding framework assemblies can be a common use case for the actual app to execute. cc @davidwrighton |
I agree. We should omit all overridable dependencies when starting the initial runtime to avoid them being loaded accidentally. It is very easy to load something accidentally if there is no enforcement. It is what I meant by the first step in my previous comment "Start the runtime with only a small set of dependencies. We may need something new for this, I am not sure.". |
Ah, got it. We don't have a built-in way to do this for |
I believe that the structured contract has been an internal implementation detail so far. Are we going to expose it and document it as a public API? I do not see a problem with it, just making sure that it is intentional lift of internal implementation detail to a public API. |
From what I've seen, I think we have to. |
Sounds good. We should write a short description for the new public API (ie the description that we will add to the docs) and agree that it is good design. |
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:
Rules of note
hostfxr_initialize_for_runtime_config
Success_HostAlreadyInitialized
: compatibleSuccess_DifferentRuntimeProperties
: technically compatible, but may impact runtime behavior. Not advised to useCoreHostIncompatibleConfig
: incompatibleConsiderations
HOST_RUNTIME_CONTRACT
structure, mono has an equivalent-ish implementation.The text was updated successfully, but these errors were encountered: