Skip to content

How to execute host native code from a hosted CLR #41319

Description

@blakemcbride

Greetings,

I have a C program that is hosting a CLR. It is able to call C# methods. However, I want to be able to have the C# code call the host's C functions too. I can't use DllImport because that would be out of the context of the C call to C#. For example:

C psudo code:

global var X = 4

init CLR
call C# myMeth

myFun() {
printf X;
}

C# psudo code:

myMeth() {
call native myFun()
}

So, C calls C# and then the C# code calls back into the host's myFun in the same context as C's call into C#. Therefore X is still visible. I am running on Linux and happy to use MS or Mono.

Thanks!

area-Interop-coreclr @jeffschwMSFT @AaronRobinsonMSFT @lambdageek

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Interop-coreclrquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions