unmanaged structs in struct with c#

J

juergen

Hello everyone,

I can't get that to work and I don't know why.
Simplified I have the following structs (Just a snip):

typedef struct
{
char* name;
int type;
Parameters1 otherStruct;
Parameters2 otherStruct2;
unsigned int lastUsed;
} TestStruct,*PTestStruct;

typedef struct Parameters1
{
Parameters3 otherStruct3;
Parameters4 otherStruct4
}Parameters1;

.......

I tried this C# class for that:

[StructLayout(LayoutKind.Sequential)]
public class TestStruct
{
[MarshalAs(UnmanagedType.LPStr)] public string name;
public int type;
public Parameters1 otherStruct;
public Parameters2 otherStruct2
public uint lastUsed;
}


But it doesn't work.
Any idea what's going wrong here?
Thanks.

greetings juergen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top