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
{{ message }}
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Multiple csproj projects referenced and using NativeCallable #7215
I can't seem to get multiple project using NativeCallableAttribute to expose these functions. Only the project that has the references (the project being compiled) has it's functions exposed as native callable functions.
We currently only look for native callable methods in the root assembly (the assembly that is getting published).
I'm not sure extending this to look at all assemblies would result in a good experience. E.g. what if there's a conflicting name of the export between two assemblies and both of them come from e.g. two different NuGets that are not under your direct control? Or what if the NuGet has a NativeCallable method you don't actually want to export?
@MichalStrehovsky
I'm actually creating a Library to make native code more approachable. The goals are:
Add a higher-level interface (built on top of FFI)
Make native functionality more discoverable
Enable cross-runtime interaction with native libraries (e.g. Native .NET called from ruby, Native .NET called from .NET, Native python called from .NET, etc)
Expand the interoperability of cross-runtime interaction
So, this project is already off the ground and doing well. I have a steel-thread that I have used in the ways described above. I'm now refactoring this into something more robust and moving the functionality around so it may be leveraged through a library. Unfortunately, I ran into this limitation :(
With AOT compilation creating a single assembly, it masks away the library's functions (of which I've named in such a way as to avoid naming conflicts). I would assume that if someone implemented a function with the same name that it would take precedence over the third-party library (my library). Or maybe there is a configuration that the implementor sets to allow the functions to pass through.
Now I've hit a new issue. I can't iterate over all of the input assemblies at run-time, from the published corert assembly. Is this currently possible? I'm trying to use this to discover the other methods that I'm extracting metadata for (reflection).
All of the assemblies are added to the rd.xml file:
Activity
MichalStrehovsky commentedon Mar 25, 2019
We currently only look for native callable methods in the root assembly (the assembly that is getting published).
I'm not sure extending this to look at all assemblies would result in a good experience. E.g. what if there's a conflicting name of the export between two assemblies and both of them come from e.g. two different NuGets that are not under your direct control? Or what if the NuGet has a NativeCallable method you don't actually want to export?
Could you describe your scenario a bit?
jkotas commentedon Mar 26, 2019
You can root more assemblies by including them in
IlcCompileInput. For example, the following should work for your example above:It would be nice to have more first class way to do this.
philcarbone commentedon Mar 26, 2019
@MichalStrehovsky
I'm actually creating a Library to make native code more approachable. The goals are:
So, this project is already off the ground and doing well. I have a steel-thread that I have used in the ways described above. I'm now refactoring this into something more robust and moving the functionality around so it may be leveraged through a library. Unfortunately, I ran into this limitation :(
With AOT compilation creating a single assembly, it masks away the library's functions (of which I've named in such a way as to avoid naming conflicts). I would assume that if someone implemented a function with the same name that it would take precedence over the third-party library (my library). Or maybe there is a configuration that the implementor sets to allow the functions to pass through.
Thoughts?
philcarbone commentedon Mar 26, 2019
Thanks @jkotas ! I'm glad there is at least a way to do this!!! Ideally, a first-class way would be better, but I'll take any way right now too :)
philcarbone commentedon Mar 30, 2019
Hi Again! (@MichalStrehovsky & @jkotas)
Now I've hit a new issue. I can't iterate over all of the input assemblies at run-time, from the published corert assembly. Is this currently possible? I'm trying to use this to discover the other methods that I'm extracting metadata for (reflection).
All of the assemblies are added to the rd.xml file:
MichalStrehovsky commentedon Apr 1, 2019
Try
AppDomain.CurrentDomain.GetAssemblies().