-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Using load_assembly_and_get_function_pointer #3676
Comments
dotnet/coreclr#23958 may answer the first question. If you are not going to "expose the full set of functionality to the connecting coreclr/native host dll", can I get the CoreCLR host from |
Yes. The nethost layer offers a few convience apis to assist with 1) locating the correct .NET Core version to load, and 2) generates the necessary initialization parameters using the standard logic. Once .NET Core (eg. coreclr) is loaded, you can then use the exports as you would before. The hope is that value comes in finding and initializing. The current nethost is a first step on a journey to enable a richer hosting experience. We did not want to lead with too much, as more comes on line. |
The We expect people to use this functionality to either make a single (or few) calls to managed code, or to build their own "interop" on top. The problem with allowing to create a native function pointer to any method is that if the method's signature is not super simple, there's no way to customize the marshaling. For example if the method would take a string argument, there would be no way to specify which encoding should be exposed to the native code... and so on. The "embedding API" which would allow native code to have much greater control over the communication with managed is something we are considering for the future. We did consider exposing the |
Thanks a lot for your answers. I would be super happy to see the "embedding APIs" in the future.
We used |
Sorry - completely missed your reply (for a long time apparently). There's a slight benefit to the current approach and that is it doesn't require us to create a new type (the delegate type) on the fly. So less "magic". I understand that it can be cumbersome if you want to use it on many public APIs. As noted above, if the use case is to call many managed methods from native, we think the better way to do that is to use the existing If you have additional questions or issues with this, please open a new issue (preferably in dotnet/runtime repo). |
Why is the new API different from the
coreclr_create_delegate
, requiring a delegate type for every different method signature?If I have a lot of methods to call, is it recommended to define delegate types or create
ComponentEntryPoint
wrappers for them?The text was updated successfully, but these errors were encountered: