gpt4 book ai didi

mono - Assembly.GetExecutingAssembly() 在嵌入式单声道中不起作用?

转载 作者:行者123 更新时间:2023-12-01 14:59:36 24 4
gpt4 key购买 nike

我正在尝试将单声道嵌入到 C++ 可执行文件中,但单声道在 Assembly.GetExecutingAssembly 上崩溃。知道我错过了什么吗?

编辑:使用单声道 3.0.3

嵌入式单声道测试.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.

最佳答案

您没有在程序中执行任何程序集,因此该上下文中的 ExecutingAssembly 没有任何意义(尽管需要更好的错误)。您需要在程序集中提供通常的静态 Main() 入口点并使用 mono_runtime_exec_main() 执行它。

关于mono - Assembly.GetExecutingAssembly() 在嵌入式单声道中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com