Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6756419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:31:18+00:00 2026-05-26T13:31:18+00:00

I want to be able to call methods on CLR classes from C++. In

  • 0

I want to be able to call methods on CLR classes from C++. In particular some classes may contain overloaded methods, so I need to search a class’s methods based both on method name and parameter signature.

I have a function like this:

MonoMethod* find_method (
    MonoDomain* domain, 
    MonoClass* type, 
    const char* name, 
    int nargs,
    MonoClass** types)    

I iterate over the members of the class, finding a matching member by name. I then need to check the parameters of the method and see whether they match the list required in the types parameter of this function.

mono_signature_get_params() is then used to iterate over the parameters for each method with a matching name.

Questions:
How can I do the following:

  1. access the MonoClass and MonoType struct fields
    • attempting to access fields in these structs results in error, as incomplete structs
  2. compare a list of method parameters with another list provided as input to the function
    • cannot compare by enum as cannot access the enum field (see above)
  3. get MonoClass* constants for fundamental types int32_class, int64_class, etc.
    • want to be able to easily compose a signature array using primitive type class constants

Here are 2 auxilliary functions that do not compile as when accessing fields in MonoType* or MonoClass*, the compiler complains indicating the two structures are incomplete:

//
//  Detetermine whether classes A and B are equivalent
//
static bool IsEquivalent (MonoType* typeA, MonoType* typeB)
{
    MonoTypeEnum Ta = typeA->type; 
    MonoTypeEnum Tb = typeB->type;

    // if basic type not a match, can punt
    if (Ta != Tb)
        return false;

    // if simple type, nothing further to check 
    if (Ta < MONO_TYPE_PTR)
        return true;

    // check class
    if (Ta == MONO_TYPE_CLASS)
        return typeA->data.klass = typeB->data.klass;
    else
        return typeA->data.klass = typeB->data.klass;        
}


//
//  Determine whether parameters in signature match incoming parameters
//
static bool types_match (
    MonoMethodSignature* sig, 
    MonoClass** types, 
    int nargs)
{
    void* iter = NULL;
    MonoType* type = NULL;

    int i = 0;
    while (type = mono_signature_get_params (sig, &iter))
    {
        if (!IsEquivalent (type, types[i++]->this_arg))
            return false;
    }

    return true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:31:19+00:00Added an answer on May 26, 2026 at 1:31 pm

    You must not include the private mono headers: your app will break when we make changes to the internals.

    To access the type enum value from a MonoType* you need to call the mono_type_get_type () function (from metadata/metadata.h). For MONO_TYPE_CLASS and MONO_TYPE_VALUETYPE you can access the MonoClass* value with mono_type_get_class ().

    To compare two signatures for equality you can use mono_metadata_signature_equal(): note that using MonoClass* to represent an argument’s type is fundamentally incorrect, since that can’t represent, for example, an argument passed by reference.

    If you need to match by assignability, you can use mono_class_is_assignable_from(), but note that you will need to deal with byref arguments, decide if you want to allow enum types to autoconvert to their underlying integer type etc.

    The fundamental type classes can be trivially retrieved with functions like:
    mono_get_int32_class(), mono_get_boolean_class() etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary I want to be able to call a JavaScript function from a Flex
I want to be able to make an HTTP call updating some select boxes
I have a non-static C# class with some instance methods, which I need to
I want my app to be able to tell whether a call was missed,
I want to stop outgoing call and open the application. The app is able
Want to be able to provide a search interface for a collection of objects
i just want to be able to call a javascritp subroutine on the client,
I'm using LaTeX and BibTeX for an article, and I want to able to
I want to be able to capture the exception that is thrown when a
I want to be able to do: For Each thing In things End For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.