0

Objective-c で書かれた MacOSX アプリに Mono を埋め込んでいます。

私は C# lib (DDL) にアクセスしています。これには、さまざまな型を返す一連の静的メソッドのみが含まれています。これまでのところ、返されたint、double、およびstringを正常に取得できますが、返された配列を取得するのに問題があります...

たとえば、int を取得する方法は次のとおりです。

MonoDomain *domain = mono_jit_init("TestDomain");

NSBundle* mainBundle = [NSBundle mainBundle];
NSString* dll = [mainBundle pathForResource:@"TestLib86" ofType:@"dll"];

MonoAssembly* assembly = mono_domain_assembly_open(domain, [dll UTF8String]);

MonoImage* image = mono_assembly_get_image(assembly);

// Get INTEGER

// get a method handle to whatever you like
const char* descAsString = "MiniLib86.Show:GetInt()";
MonoMethodDesc* description = mono_method_desc_new(descAsString,TRUE);
MonoMethod* method = mono_method_desc_search_in_image(description, image);

// call it
void* args[0];
MonoObject *result = mono_runtime_invoke(method, NULL, args, NULL);    
int int_result = *(int*)mono_object_unbox (result);

// See the result in log
NSLog(@"int result %i", int_result);

List を返す C# のメソッドは次のようになります。

public static List<int> GetListInt()
{
    return new System.Collections.Generic.List<int>{1,2,3,4,5};
}

どんな助けでも本当に感謝します!

4

1 に答える 1