C
C#3w ago
GigaElmo

Mono vm not allowing me to call the constructor on a class that inherits from another class

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Frekit;

namespace CSAssembly
{
public class Vinny : Behaviour
{
public void Awake()
{
Console.WriteLine("Vinny woke up");
}
private void SayHi()
{
Console.WriteLine("Hi");
}
public Vinny()
{
Console.WriteLine("Vinny has been summoned");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Frekit;

namespace CSAssembly
{
public class Vinny : Behaviour
{
public void Awake()
{
Console.WriteLine("Vinny woke up");
}
private void SayHi()
{
Console.WriteLine("Hi");
}
public Vinny()
{
Console.WriteLine("Vinny has been summoned");
}
}
}
this is the class im trying to instanciate
static void init() {
std::string libPath = (std::filesystem::current_path() / "lib").string();
std::string etcPath = (std::filesystem::current_path() / "etc").string();

mono_set_dirs(libPath.c_str(), etcPath.c_str());
domain = mono_jit_init("GameLib");

mono_add_internal_call("Frekit.Behaviour::AddCalls", addCalls);
mono_add_internal_call("Frekit.Behaviour::RemoveCalls", removeCalls);
mono_add_internal_call("Frekit.Module::GetInstanceID", getInstanceID);


coreAssembly = mono_domain_assembly_open(domain, "bin/Frekit.Core.dll");
assembly = mono_domain_assembly_open(domain, "bin/CSAssembly.dll");

coreImage = mono_assembly_get_image(coreAssembly);
image = mono_assembly_get_image(assembly);

MonoClass* vinnyClass = mono_class_from_name(image, "CSAssembly", "Vinny");
MonoClass* behaviourClass = mono_class_from_name(coreImage, "Frekit", "Behaviour");
MonoClass* moduleClass = mono_class_from_name(coreImage, "Frekit", "Module");
MonoObject* vinny = mono_object_new(domain, vinnyClass);
mono_runtime_object_init(vinny); // Throws error, something about null method info
mono_runtime_invoke(earlyBirds[*(uint64_t*)mono_object_unbox(getInstanceID(vinny))], vinny, NULL, NULL);
return;
}
static void init() {
std::string libPath = (std::filesystem::current_path() / "lib").string();
std::string etcPath = (std::filesystem::current_path() / "etc").string();

mono_set_dirs(libPath.c_str(), etcPath.c_str());
domain = mono_jit_init("GameLib");

mono_add_internal_call("Frekit.Behaviour::AddCalls", addCalls);
mono_add_internal_call("Frekit.Behaviour::RemoveCalls", removeCalls);
mono_add_internal_call("Frekit.Module::GetInstanceID", getInstanceID);


coreAssembly = mono_domain_assembly_open(domain, "bin/Frekit.Core.dll");
assembly = mono_domain_assembly_open(domain, "bin/CSAssembly.dll");

coreImage = mono_assembly_get_image(coreAssembly);
image = mono_assembly_get_image(assembly);

MonoClass* vinnyClass = mono_class_from_name(image, "CSAssembly", "Vinny");
MonoClass* behaviourClass = mono_class_from_name(coreImage, "Frekit", "Behaviour");
MonoClass* moduleClass = mono_class_from_name(coreImage, "Frekit", "Module");
MonoObject* vinny = mono_object_new(domain, vinnyClass);
mono_runtime_object_init(vinny); // Throws error, something about null method info
mono_runtime_invoke(earlyBirds[*(uint64_t*)mono_object_unbox(getInstanceID(vinny))], vinny, NULL, NULL);
return;
}
and this is how im trying to do it from cpp
2 Replies
GigaElmo
GigaElmoOP3w ago
mono_runtime_object_init throws a null exception even through all the data ive loaded is not null. ive broken the problem down to the fact that it has something to do with vinny inheriting from another class
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server