I googled a lot & nothing is working in my case. Here is my code.
.cpp
char* pp = "this_is_text";
DLL_EXPORT void ToString_Internal(MicroObject* a_microObj, char* a_str)
{
*a_str = *pp;
}
#define DLL_EXPORT __declspec(dllexport)
C# (import)
[DllImport("Serializer", CharSet = CharSet.Ansi)]
private extern static void ToString_Internal(IntPtr a_ptr, StringBuilder a_builder);
C# (usage)
StringBuilder l_builder = new StringBuilder(1000); //set 1000 len, for testing
ToString_Internal (m_ptr, l_builder); //invoke to DLL function
Console.WriteLine (l_builder.ToString ()); //print to console
Question #1: Console.WriteLine() prints only first letter("t") in terminal. What is this issue?
Question #2: i am allocating memory in C#(using StringBuilder). Is C# GC deallocating memory in my case or do i have to deallocate memory manually and in which side(C or C#).
If you guyz need more info, let me know.
*a_str = *pp;- you understand that copies exactly one character, right ?