How explore the .NET core assembly using reflection(with Unmanaged API ) from the unmanaged C++ code

62387145 1 Reputation point


I would like to get all the types and methods from the .NET core assembly from the unmanaged C++ code.
Then I want to invoke the method from the unmanaged C++ by hosting the .NET core runtime.

It should be some thing like, I need to load the .NET Core assembly in C++ and expecting to return the __Assembly object, from there I need to explore all the types and methods provided by this assembly. Then execute the method from the C++.

I couldnt find any documentation to get the types and methods of the .NET Core assembly using Unmanaged API. I found docs for .Net framework, but it is failing for the .Net core assembly.

Please let me know, how to get the below information for the .Net Core assembly:

1- How can I explore the .NET core assembly using reflection from the unmanaged C++ code.
2- How can I invoke the .NET Core assembly method from the unmanaged C++ code.
3- Or is there Microsoft documentation for the UnManaged API reference for the .Net Core ?
4- Is there any way/technic to distinguish .Net framework assembly and .Net Core assembly ?


A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,631 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,141 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 61,416 Reputation points

    While doable, your is an advanced project. C# is designed to interact with native apis (C/C++) via parameters marshaling via attributes and p-invoke method. The focus is on C# calling C/C++ methods, and handling callbacks. you want C/C++ to call generic methods that have not been prepped.

    first your C/C++ code must host the .net core dll via the core cli. the car will load the C# code, and will interpret or jit and execute the IL code.

    here is the source:

    here is an example of call reflection:

    you might find it easier to write a C# library that implements the reflection features you want and then host this library.

    1 person found this answer helpful.
    0 comments No comments