-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
How can one call/consume a .NET Assembly from a native binary? #34571
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
There is no straightforward way to publish .NET library as unmanaged library with C/C++ entrypoints today. The closest thing that works today is hosting the runtime. The documentation is at |
dotnet publish
@brimonk I have been working on a project for exposing C exports for a .NET assembly. It doesn't yet create a single binary for distribution, but it is a start. I mentioned it at #3750 (comment). |
As mentioned, the prototype project DNNE demonstrates an example of what is suggested in #34571 (comment). |
Put simply, I would like to attempt to call some C# code from an existing C/C++ codebase. In my experience in the past, I have generally found this to be hard, calling into a managed runtime from an unmanaged runtime, but I expected it might be possible as it seemed that dotnet compiled down into a .dll/.so of some sort, and was just called from a loading program.
Just for the record, I am trying to do this on Ubuntu 19.04.
So, I created a simple classlib by using,
dotnet classlib
. I filled out an example class within the given namespace that looked something like this:public class Foo { public int Add(int a, int b) { return a + b; } }
. Then I attempted to usedotnet publish
to get something that would be close to a Unix shared object (.so), and to my surprise, there wasn't one.All I got was a .dll.
According to the documentation for the command, you can supposedly use the -r flag to set the runtime. So, I tried the
linux-x64
,osx-x64
andwin-x64
and only got PE32+ .dll's.What's going on? Is it impossible to "just get a binary" from the dotnet core compiler? I know that C# compiles to an intermediate representation from within that .dll, but is there a way to skip that step, and compile a shared C# library into a "regular" library?
The text was updated successfully, but these errors were encountered: