0
C#을 사용하여 iPhone 용 응용 프로그램을 빌드하는 동안이 버그가 발견되었습니다. 이 응용 프로그램에는 System.Object 인스턴스를 c.I에 전달하는 플러그인이 있습니다.이 부분에는 어떤 부분이 없는지 확실하지 않습니다! 관리 (래퍼에서MarshalDirectiveException (래퍼에서 네이티브로 관리 됨)
MarshalDirectiveException
: 여기
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);
}
오류 MSG이다
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);
여기
은 C 코드이다 : 여기
는 C# 코드이다 - 네이티브) CSharpToMonoClass : MonoDelegateToPtr (intptr, in t, object, string, int)
사실 난 System.Object 인스턴스를 보내고 C에서 조작됩니다 C#에 대한 래퍼를 만들어 모노 아이폰에 역방향 콜백 문제를 해결하기 위해 노력했다. –
거기에 또 다른, 내장, 솔루션이 많이 있습니다 좋지만 정적 메서드에 대한 대리자에 대해서만 작동합니다. Marshal.GetFunctionPointerForDelegate를 사용하고 MonoPInvokeCallbackAttribute를 사용하여 정적 메서드를 꾸미십시오. –
최고 감사 Rolf! 방금 시도하고 작동합니다! –