Skip to content

hostfxr_run_app & hostfxr_get_runtime_delegate #76358

Answered by vitek-karas
wingchunninja asked this question in Q&A
Discussion options

You must be logged in to vote

The hostfxr_run_app will only return once Main returns at which point the runtime shuts down. So using stuff after that is not possible.

There are two possible solutions if you need to have:

  • Custom host - so that you control how the runtime is loaded
  • Running managed app inside the process
  1. You could just call Main as a normal method. This comes with some gotchas:
  • Normally Main will not return until the app is done, so may want to do this on a new thread and let it sit there (depends on what it does)
  • Some things will not be initialized the same way they would be with hostfxr_run_app. For example things like Environment.GetCommandLineArgs will not return any value. It's unlikely this wo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wingchunninja
Comment options

Answer selected by wingchunninja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants