Search code examples
c#c++monoclrclr-hosting

Is "mono_add_internal_call" just with CLR-Hosting possible?


is there any function to have the same possibilities like "mono_add_internal_call" in the CLR-Hosting w/o using mono?

Mono

C++ Code:

static MonoString* Sample ()
{
  return mono_string_new (mono_domain_get(), "Hello!");
}
mono_add_internal_call ("Hello::Sample", Sample);

C# Code:

using System;
using System.Runtime.CompilerServices;

class Hello {
    [MethodImplAttribute(MethodImplOptions.InternalCall)]
    extern static string Sample ();
}

Thanks


Solution

  • Instead of "mono_add_internal_call", I use now P/Invoke. It has the same results. So if you call an C# DLL with CLR-Hosting, the P/Invoke calls the CLR-Hosting Dll and not create a new instance.

    Thanks to Lucas.