3

Mono を C++ 実行可能ファイルに埋め込もうとしていますが、Mono が Assembly.GetExecutingAssembly でクラッシュします。私が見逃したもののアイデアはありますか?

編集:モノ3.0.3を使用

EmbeddedMonoTest.cpp :

// EmbeddedMonoTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>

int _tmain(int argc, _TCHAR* argv[])
{
    MonoDomain* domain = mono_jit_init_version ("ClassLibrary1", "v4.0.30319");
    MonoAssembly* _assembly_fbmonoengine    = mono_domain_assembly_open (domain, "ClassLibrary1.dll");  
    MonoImage* _image_fbmonoengine      = mono_assembly_get_image (_assembly_fbmonoengine);
    MonoClass* klass = mono_class_from_name(_image_fbmonoengine, "ClassLibrary1", "Class1");
    MonoMethod* test = mono_class_get_method_from_name(klass, "Test"    , 0);
    mono_runtime_invoke(test, NULL, NULL, NULL); 
    return 0;
}

Class1.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ClassLibrary1
{
    public class Class1
    {
        public static void Test()
        {
            Assembly.GetExecutingAssembly();
        }
    }
}

エラー :

Unhandled exception at 0x65ad2148 in EmbeddedMonoTest.exe: 0xC0000005: Access violation reading location 0x`00000008.
4

1 に答える 1

2

You're not executing any assembly in your program, so ExecutingAssembly in that context has no meaning (a better error is needed, though). You need to provide the usual static Main() entry point in the assembly and execute it with mono_runtime_exec_main().

于 2013-02-17T08:02:25.707 に答える