Question about coreclr, hostfxr and nethost in net 8 or 9 #110885
-
Hello everyone, I want to know. But I don't understand why does @tannergooding write old example from old repository about native-hostfxr but I really want to know how do I load assembly inside dotnet 8 or 9 because I want create simple embedded library ( libdotnetapp_interop.a ) in Dotnet's Console
But I really want to know how do I get success initializing if I get "Failed to initialize coreclr!" But I don't know. But I never make statically with libraries of Net/Dotnet SDK. I really want to have own example if I understand correctly. Make sure example of implemented function from C/C++! What do I need know for app_domain? Example Managed assembly:
But Unmanaged P/invokes I know that. like in C/C++:
Because I want to learn about it. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
It's unclear about what do you want to achieve. To better express your intend and failures, you can highlight the following points: How many module of code are you trying to connect together, 2 or 3? What's the language and runtime environment of each module? What's the interface you were using to load them? |
Beta Was this translation helpful? Give feedback.
-
I'm unsure what sample you're referring to, can you provide a link? |
Beta Was this translation helpful? Give feedback.
To summarize:
Your host and entry application is native and developed in C. The CLR instance is hosted by the C application. The bridge should be established via either nethost.h, or nativeaot.
The error message "Failed to initialize coreclr!" sounds like there's another CLR instance already running in the process, used by any service. CLR doesn't support co-existence within the same process. In this case, using nativeaot should be the only option.