I have a lib that returns a CFString, and I'm trying to get that string value in C#.. The problem is that I don't know how to do this in C#..
Making the external function return a CFString won't work as it throws an exception "Type MonoMac.CoreFoundation.CFString which is passed to unmanaged code must have a StructLayout attribute."
Then I thought that I could get the string as a byte array and then convert it to a string in C#, but then, I have another problem, I don't know how to convert in C the CFString to a byte array :/
C# Dll Import stuff
[DllImport("lib")]
public static extern MonoMac.CoreFoundation.CFString test();
[DllImport("lib")]
public static extern byte[] test();
C Library sample
CFStringRef test()
{
return CFSTR("test string");
}
If anyone knows a way to do this please help me out ;)
Thanks