hostfxr_run_app & hostfxr_get_runtime_delegate #76358
-
Hi everyone, I have a .net6.0 application that I call from unmanaged code. If I call only hostfxr_get_runtime_delegate, I have the problem that the Main/Startup classes from my .net application are not being called, and that leads to the point where crucial things that I use in the component class are not being initialized. Is there a possibility to first call hostfxr_run_app and then hostfxr_get_runtime_delegate. What I have tested is that calling hostfxr_run_app works and initialized the app, but after that calling hostfxr_get_runtime_delegate on the same contextHandle results into me receiving an EXC_BAD_ACCESS (code=1, address=0x986d41350c08). Do you have some ideas how i can use a hybrid from both, initializing the app and after that calling the component? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The There are two possible solutions if you need to have:
|
Beta Was this translation helpful? Give feedback.
The
hostfxr_run_app
will only return onceMain
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:
Main
as a normal method. This comes with some gotchas: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)hostfxr_run_app
. For example things likeEnvironment.GetCommandLineArgs
will not return any value. It's unlikely this wo…