hello,
i'm working on a way to load a dll i made in C into C#. I made a simple function that returns a string "hello" and C# calls this function and gets the string just fine. I then tried to pass a structure to C#, but this causes errors.

my C code structure
Code:
typedef struct _MY_STRUCT
{
int  sName;
int  sPhone;
}MY_STRUCT, *LPMY_STRUCT;
my C# structure
Code:
        public struct MY_STRUCT
        {
            public int sName;
            public int sPhone;
        }

whenever I call
Code:
            
MY_STRUCT MyStruct = new MY_STRUCT();

//MessageBox.Show(Marshal.SizeOf(MyStruct).ToString());

//compiler doesnt like this line...
Marshal.PtrToStructure(GetString(), MyStruct);
            
MessageBox.Show(MyStruct.sName.ToString());
MessageBox.Show(MyStruct.sPhone.ToString());
I get a runtime error: "The structure must not be a value class.
Parameter name: structure"

I've also just tried doing this:
Code:
MyStruct = GetString(); //GetString is just the name of the function
but all i get is a runtime error saying type signiture is not compatible
by using sizeof, I know that both the C structure and the C# structure are 8 bytes long, but I dont know what else to do (and ive tried everything I could think of)

Please, could someone help me?