Re: Pointer of Struct
- From: "<ctacke/>" <ctacke[at]opennetcf[dot]com>
- Date: Thu, 26 Jul 2007 09:41:14 -0500
You wouldn't want that anyway. Since they're defined as non-fixed length
string, they would be stored as pointers, and the size of the struct is
actually 8 bytes. This makes me a little wary of what it is you're trying
to send this data to. What is the API expecting as far as data layout?
Right now you have a struct with two pointers that point to string data. Is
that what you need, or is it expecting a stuct with fixed-length character
arrays?
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
"Sasacha Jakob" <sjakob@xxxxxxxxxx> wrote in message
news:eOi31T4zHHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
i have a problem while using
Marshal.SizeOf(...) on Windows CE 5.0
I get a NotSupportedException.
Here is my whole procedure:
public struct MyPerson {
public string first;
public string last;
}
private unsafe void Test() {
MyPerson myP = new MyPerson();
myP.first = "Tom";
myP.last = "Stevens";
// Get Pointer of myP
int size = Marshal.SizeOf(myP); // This Method throws the Exception
IntPtr buffer = Marshal.AllocCoTaskMem(size);
Marshal.StructureToPtr( myP, buffer, false );
}
When I try to run this Code as a Windows Desktop Application it runs
great.
When I use the following struct (using char instead of string) it runs on
Windows CE 5.0 as well:
public struct MyPerson {
public char first;
public char last;
}
But I need string members of the sruct. What is my problem, and what can I
do.
Is this function of getting a pointer of struct actually not available on
Windows CE 5.0
Please Help me, thank you.
Best Regards
Sascha Jakob
.
- References:
- Pointer of Struct
- From: Sasacha Jakob
- Pointer of Struct
- Prev by Date: RE: Pointer of Struct
- Next by Date: Re: Roaming message box appear clicking send/receive mail button
- Previous by thread: Re: Pointer of Struct
- Next by thread: Disable power off on WM5
- Index(es):