我正在尝试将单声道嵌入到c ++可执行文件中,并且单声道崩溃在第二个评估器上。运行(..)如下所示。知道我错过了什么?
使用mono 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 = mono_domain_assembly_open (domain, "ClassLibrary1.dll");
mono_assembly_get_image(mono_domain_assembly_open (domain, "Mono.CSharp.dll"));
MonoImage* image = mono_assembly_get_image (assembly);
MonoClass* klass = mono_class_from_name(image, "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.Reflection;
using Mono.CSharp;
namespace ClassLibrary1
{
public class Class1
{
public static void Test()
{
var assembly = Assembly.GetAssembly(typeof(Class1));
CompilerSettings settings = new CompilerSettings();
ReportPrinter printer = new ConsoleReportPrinter();
CompilerContext context = new CompilerContext(settings, printer);
Evaluator evaluator = new Evaluator(context);
evaluator.ReferenceAssembly(assembly);
evaluator.Run("using System; using ClassLibrary1;");
evaluator.Run("Action<object> action = args => {{ 'x'.ToString(); }}; ");
evaluator.Run("Action<object> b = args => {{ 'x'.ToString(); }}; ");
}
}
}
错误:
Unhandled exception at 0x0274b00d in EmbeddedMonoTest.exe: 0xC0000005: Access violation reading location 0x00000000.