Marshal.StructureToPtr supported in compact framework?

A

Abhi

Hi,

I am repeatedly getting the NotSupportedException with
Marshal.StructureToPtr and Marshal.PtrToStructure in compact
framework. Could someone please clarify if they are supported on
compact framework? I am using a WM6 professional T-Mobile phone in the
VS 2005 environment.

Below are the exception details:
System.NotSupportedException was unhandled
Message="NotSupportedException"
StackTrace:
at System.Runtime.InteropServices.Marshal.StructureToPtrInternal()
at System.Runtime.InteropServices.Marshal.StructureToPtr()
at Something.SomethingElse.RawSerializeEx()
at SomeStruct.toByteArray()
at Something.WZCSAPI.DoSomething()
at Something.Form1.linkLabel1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.LinkLabel.OnKeyDown()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.LinkLabel.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at Something.Program.Main()


Thanks,
Abhi
 
C

Chris Tacke, MVP

I believe they both work (certain that StructureToPtr does, not as certain
with PtrTo Structure, but still pretty sure it does), but only with limited
types of structures. Complex or compound structures simply won't marshal,
which is why the SDF code that already does all the stuff you've been doing
for several days now doesn't use it.

-Chris
 
A

Abhi

Hi Chris,

The reason I am trying to do PtrToStructure is to get the
WZC_802_11_CONFIG_LIST struct from the INTF_ENTRY_EX.rdSSID which is
of type RAW_DATA (unmanaged data). I need this struct to get the list
of preferred access points. Like you say, SDF does not do this. Could
you please let me know if this is at all possible?

Thanks,
Abhi
 
D

davidknechtges

Hi Chris,

The reason I am trying to do PtrToStructure is to get the
WZC_802_11_CONFIG_LIST struct from the INTF_ENTRY_EX.rdSSID which is
of type RAW_DATA (unmanaged data). I need this struct to get the list
of preferred access points. Like you say, SDF does not do this. Could
you please let me know if this is at all possible?

Thanks,
Abhi

Have you looked at the WirelessZeroConfigNetworkInterface class in the
SDF and its property PreferredAccessPoints?
 
A

Abhi

Yes. I have. But it only has limited information in it (just the SSID,
Signal strength etc). But I was looking for
WZC_WLAN_CONFIG.KeyMaterial which is the network key in bytes. Do you
know any SDF class that contains this or something similar?

Thanks,
Abhi
 
P

Paul G. Tobey [eMVP]

What do you want to do with it? The bytes themselves are not readable. If
what you've previously said is true, that *what* you are trying to do is get
the list of preferred access points, you don't need the key material bytes
for that. Look at AccessPointCollection.internal unsafe void
RefreshListPreferred( bool nearbyOnly ) for the case of nearbyOnly = false.

Paul T.
 
A

Abhi

What do you want to do with it?  The bytes themselves are not readable. If
what you've previously said is true, that *what* you are trying to do is get
the list of preferred access points, you don't need the key material bytes
for that.  Look at AccessPointCollection.internal unsafe void
RefreshListPreferred( bool nearbyOnly ) for the case of nearbyOnly = false.

I need it for an app where I'll be transporting Preferred AP's from
one device to another. In order to do this, I'll need the keyMaterial
in bytes as well as the SSID. Could you please let me know if this can
be done?
 
A

Abhi

What do you want to do with it?  The bytes themselves are not readable. If
what you've previously said is true, that *what* you are trying to do is get
the list of preferred access points, you don't need the key material bytes
for that.  Look at AccessPointCollection.internal unsafe void
RefreshListPreferred( bool nearbyOnly ) for the case of nearbyOnly = false.

Hi Paul,

What do you mean when you say the bytes are not readable? Can't we
access them in the form of bytes?
 
P

Paul G. Tobey [eMVP]

The key material is not portable. If it were, that would be completely
insecure and worthless.

Paul T.

What do you want to do with it? The bytes themselves are not readable. If
what you've previously said is true, that *what* you are trying to do is
get
the list of preferred access points, you don't need the key material bytes
for that. Look at AccessPointCollection.internal unsafe void
RefreshListPreferred( bool nearbyOnly ) for the case of nearbyOnly =
false.

I need it for an app where I'll be transporting Preferred AP's from
one device to another. In order to do this, I'll need the keyMaterial
in bytes as well as the SSID. Could you please let me know if this can
be done?
 

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