You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem with hostfxr_initialize_for_runtime_config is that the trusted platform assemblies (TPA) will only contain that version's assemblies. If you reference a newer version of a runtime's assembly, the assembly load context will always load the runtime version not your referenced version. There is no way to intercept the loading of this TPA. When creating a dotnet application this does not occur as the runtime is loaded using the hostfxr_initialize_for_dotnet_command_line method which uses the .runtimeconfig.json and (importantly) .deps.json. You can then continue to use the runtime as if it was loaded using hostfxr_initialize_for_runtime_config.
Thank you for your contribution, I'll try to read up and review it shortly. The macos tests failing is probably due to the recent update of the Github macos-latest runners to 14, which breaks a lot of tests.
TestFrameworks.zip
Attached is my minimal failing example. If you run the dotnet app it all works fine. If you run the python app it fails. The reason is that the Hosting reference which is pinned to 8.0 has a reference to DiagnosticSource which it expected to be 8.0. The version in the TPA list is 6.0 due to the 6.0 framework loaded. It then fails because metrics don't exist in that version.
Thank you very much for this and sorry for only merging it so late. I will adjust this slightly in a separate PR to allow us to default to this eventually (making it a flag in get_coreclr instead of a separate function).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem with
hostfxr_initialize_for_runtime_configis that the trusted platform assemblies (TPA) will only contain that version's assemblies. If you reference a newer version of a runtime's assembly, the assembly load context will always load the runtime version not your referenced version. There is no way to intercept the loading of this TPA. When creating a dotnet application this does not occur as the runtime is loaded using thehostfxr_initialize_for_dotnet_command_linemethod which uses the.runtimeconfig.jsonand (importantly).deps.json. You can then continue to use the runtime as if it was loaded usinghostfxr_initialize_for_runtime_config.See for details on different ways to initialize https://github.com/dotnet/runtime/blob/main/docs/design/features/native-hosting.md#initializing-host-context