Home All Groups Group Topic Archive Search About

unmanaged structs in struct with c#

Author
13 Apr 2006 11:20 AM
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

Author
14 Apr 2006 12:18 AM
Mattias Sjögren
>But it doesn't work.

In what way is it failing?


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Are all your drivers up to date? click for free checkup

Author
14 Apr 2006 7:28 AM
juergen
> In what way is it failing?

The application just terminates when I call the method that has this struct as parameter.

juergen

Bookmark and Share