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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:16:48+00:00 2026-06-09T01:16:48+00:00

I found this bug error while building an application for iPhone using c#. This

  • 0

I found this bug error while building an application for iPhone using c#.
This application has a plugin that passes System.Object instance to c.I got this and Im not sure what part is missing!

Here is the C# code:

public static void Call( System.IntPtr L, System.Delegate pDelegate)
{   
    MonoDelegateToPtr( L, 0, pDelegate.Method.Target, pDelegate.Method.Name, pDelegate.Method.GetParameters().Length);
}

[System.Runtime.InteropServices.DllImport("__Internal")]
static extern void MonoDelegateToPtr( System.IntPtr L, int pN, System.Object pObj, string pMethod, int pParamCount);

Here is the C code:

extern "C" void MonoDelegateToPtr( lua_State* L, int pN, MonoObject* pObj, const char* pMethod, int pParamCount)
{
   MonoMethod *method;

   MonoObject *pObject;
   method = GetCSMethod( pObject, pMethod, pParamCount);
   lua_CFunction func = (lua_CFunction)[MonoUtility MonoDelToPtr: method];
   if( func==0)
   {
      printf("****ERROR DELEGATE TO FUNCTION PTR IS NULL%s\n", pMethod);
      return;
   }

   lua_pushcclosure( L, func, pN);
}

MonoMethod* GetCSMethod( MonoObject *pObj, const char* pMethod, int pParamsTotal)
{
   MonoClass *class = mono_object_get_class( pObj);
   MonoMethod   *methodDef = mono_class_get_method_from_name(  class, pMethod,   pParamsTotal);

   return mono_object_get_virtual_method((MonoObject*)objectInstance, methodDef);
}

Here is the error msg:

MarshalDirectiveException

at (wrapper managed-to-native) CSharpToMonoClass:MonoDelegateToPtr (intptr,int,object,string,int)

  • 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-09T01:16:49+00:00Added an answer on June 9, 2026 at 1:16 am

    The problem is that the marshaller does not know how to marshal a System.Object.

    I believe you can use an IntPtr, and the following trick to transform a System.Object to an IntPtr:

    struct ObjWr {
        [FieldOffset (0)] IntPtr ptr;
        [FieldOffset (0)] object obj;
    }
    

    and then store the object in the obj field and read back the pointer from the ptr field.

    However I am not entirely sure this is the right approach to what you’re trying to do, but it’s not clear to me what you’re actually trying to do, so maybe you can explain that a bit better?

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

Sidebar

Related Questions

I've found a possible bug while i was using jquery and Ajax function on
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even
I just found out this weird behavior, is this a bug or what am
Found this while reading the Neo4j manual, specifically here , I found the sentence:
found this little code snippet that seems to do what i want, but im
Found this question that explained a way to communicate between layers. However there is
Update: A sample project reproducing this bug can be found here at Microsoft Connect
Several times while debugging a VB.Net program I have found that continuation lines are
I'm using Saxon-EE 9.3.0.4 for xsl transformations and found that when <xsl:result-document> is used
Is there anything wrong in function shown below. The only bug that I found

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.