FieldOffset in SmartDevice project

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

Is there anybody who tried to use the FieldOffset attribute in Compact Framework? I see the online help, and the Microsoft write "in Explicit type in StructLayout is supported by the .NET Compact Framework". And when I use it, it makes an exception "FieldOffset could not be found". It's very important to me

If somebody can help me, I will thank it very much

(Sorry for bad english :-

Zsomb

ps: here is a simple test cod

using System.Runtime.InteropServices

[StructLayout(LayoutKind.Explicit)
public class testclas

[FieldOffset(0)] public int left; > first exceptio
[FieldOffset(2)] public int right; > and again exceptio
}
 
Zsombi said:
Is there anybody who tried to use the FieldOffset attribute in
Compact Framework?

I don't believe it's supported by the Compact Framework.
I see the online help, and the Microsoft write "in
Explicit type in StructLayout is supported by the .NET Compact
Framework".

Where does it say that, out of interest?
 
Hi

Thanks for the answer. We see this site at first

http://msdn.microsoft.com/library/d...RuntimeInteropServicesLayoutKindClassTopic.as

It writes "Supported by Compact Framework

And now we are navigating the next site

http://msdn.microsoft.com/library/e...eropservicesfieldoffsetattributeclasstopic.as

You told the truth: it doesn't supported by CF

But it isn't clear to me. Why does it support the LayoutKind.Explicit, and doesn't support the FieldOffset

form the MSDN
FieldOffset: "This attribute is used when System.Runtime.InteropServices.StructLayoutAttribute, with LayoutKind.Explicit ...

Thanks agai

Zsombi
 
Zsombi said:
Thanks for the answer. We see this site at first:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre
f/html/frlrfSystemRuntimeInteropServicesLayoutKindClassTopic.asp
Right.

It writes "Supported by Compact Framework"

And now we are navigating the next site:

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemruntime
interopservicesfieldoffsetattributeclasstopic.asp

You told the truth: it doesn't supported by CF.

But it isn't clear to me. Why does it support the
LayoutKind.Explicit, and doesn't support the FieldOffset?

Possibly there's some internal use of Explicit - not sure. Either way,
it doesn't look like you're going to be able to set the field offset :(
 
In the CF sequential layouts are the only supported option. You'll have to
manually do the offsets or use a BitVector32 for bit field offsets.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com



Zsombi said:
Hi all,

Is there anybody who tried to use the FieldOffset attribute in Compact
Framework? I see the online help, and the Microsoft write "in Explicit type
in StructLayout is supported by the .NET Compact Framework". And when I use
it, it makes an exception "FieldOffset could not be found". It's very
important to me.
If somebody can help me, I will thank it very much!

(Sorry for bad english :-)

Zsombi

ps: here is a simple test code

using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Explicit)]
public class testclass
{
[FieldOffset(0)] public int left; > first exception
[FieldOffset(2)] public int right; > and again exception
}
 
Back
Top