Problem using "MarshalAs"

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

Guest

Hello guys,
I have a problem in my cf c# application:

On top declaration there is "using System.Runtime.InteropServices;" and
following my source I want use this declaration,
"[MarshalAs( UnmanagedType.ByValArray, SizeConst=6 )] public Int32 [] Ip;

for compiler I'm less using directive declaration or assembly referement
regarding attribute "MarshalAs". How I can resolve this problem ??

thanks fabbrit
 
MarshalAs is not supported in the Compact Framework. If this appears within
a structure, generally the best way to workaround these limitations is to
bundle the whole structure into a single byte array and pass this into a
native function. You will have to manually write the functionality to add a
structured "wrapper" around your byte[] so it exposes a set of properties
which match what the structure actually contains. You can use the
BitConverter and Buffer classes to do most of the manipulation required.
You'll find examples of such marshalling throughout the SDF source
(www.opennetcf.org/sourcebrowse/) where we build a class with strongly typed
properties which can return a byte[] of all the data from a ToByteArray()
method.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 

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

Back
Top