❔ [UnmanagedCallersOnly] with a function that takes a string
I'm trying to make a C# library, and had success with
but once I made it
It now fails to compile with:
I understand that it seems I can't use string as a type, but not sure what else to use?
using System.Runtime.InteropServices;
namespace ToasterMap
{
static class ToasterMap
{
[UnmanagedCallersOnly(EntryPoint = "add")]
public static int Add(int a, int b) => a + b;
}
}using System.Runtime.InteropServices;
namespace ToasterMap
{
static class ToasterMap
{
[UnmanagedCallersOnly(EntryPoint = "add")]
public static int Add(int a, int b) => a + b;
}
}using System.Runtime.InteropServices;
using System;
namespace ToasterMap
{
static class ToasterMap
{
public static String tbinPath;
[UnmanagedCallersOnly(EntryPoint = "add")]
public static int Add(int a, int b) => a + b;
[UnmanagedCallersOnly(EntryPoint = "init")]
public static void Init(string tbinPath)
{
if (!File.Exists(tbinPath))
{
throw new Exception("TBin path does not exist");
}
ToasterMap.tbinPath = tbinPath;
}
}
}using System.Runtime.InteropServices;
using System;
namespace ToasterMap
{
static class ToasterMap
{
public static String tbinPath;
[UnmanagedCallersOnly(EntryPoint = "add")]
public static int Add(int a, int b) => a + b;
[UnmanagedCallersOnly(EntryPoint = "init")]
public static void Init(string tbinPath)
{
if (!File.Exists(tbinPath))
{
throw new Exception("TBin path does not exist");
}
ToasterMap.tbinPath = tbinPath;
}
}
}C:\Coding\C#\ToasterMap\ToasterMap.cs(14,33): error CS8894: Cannot use 'string' as a
parameter type on a method attributed with 'UnmanagedCallersOnly'. [C:\Coding\C#\To
asterMap\ToasterMap.csproj]C:\Coding\C#\ToasterMap\ToasterMap.cs(14,33): error CS8894: Cannot use 'string' as a
parameter type on a method attributed with 'UnmanagedCallersOnly'. [C:\Coding\C#\To
asterMap\ToasterMap.csproj]I understand that it seems I can't use string as a type, but not sure what else to use?
char[]char[] and byte[]byte[] also fails