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 8787913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:00:55+00:00 2026-06-13T22:00:55+00:00

The scenario is pretty straighforward, I’ve embedded mono runtime 2.10.8 in my app, and

  • 0

The scenario is pretty straighforward, I’ve embedded mono runtime 2.10.8 in my app, and I’m calling the managed methods via pointers obtained by: mono_method_get_unmanaged_thunk:

// obtain pointer
bool (__stdcall*foo) (MonoException**);
foo = mono_method_get_unmanaged_thunk(somemethod);

// call it
MonoException* exc;
foo(&exc);
if(exc)
    // handle exception
// nothing else...

What puzzles me, that I’m doing nothing else with the MonoException pointer (documentation I’ve read doesn’t say anything about this). Is it removal handled by the managed runtime? If so, how it can be sure that my native side is not holding a pointer to it?

Edit

I’ve read through the sources and found out that exceptions are just pointers to objects created with mono_object_new, so they are subject of the garbage collection.

Now, I’ve also read that if I want to keep some pointer on native side and prevent it from being garbaged I need to obtain GC handle for it. So the (modified) question now is:

If the point of returned pointer to exception object is only to serve as error reporting facility, and such error reporting is made right after the managed call, is it safe to assume it won’t get garbaged before I handle it (without using gc handle)?

  • 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-06-13T22:00:56+00:00Added an answer on June 13, 2026 at 10:00 pm

    To quote the page you linked:
    Note that this registration is not necessary for LOCAL variables, as they are stored on the stack. It is only necessary for global variables, as they are not a part of the GC’s root set.

    So that means in your scenario you don’t have to allocate a handle.

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

Sidebar

Related Questions

I have been learning managed pointers lately and ran into the following scenario. I
I think my scenario is pretty common. I have a database and I want
Its a pretty basic scenario. I have a table with a Geography datatype in
In a pretty typical scenario, I have a 'Search' text box on my web
I think this is a pretty common scenario: I have a webpage that's returning
I think this is a pretty common scenario, but I haven't been able to
Use scenario is pretty simple: I have a desktop only application that could be
Pretty simple scenario: I'm using Spring and Spring Security, and I'm trying to inject
This is a pretty basic scenario but I'm not finding too many helpful resources.
The following scenario pretty much sums up my problem: Scenario: problems with subprocesses Given

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.