This project is read-only.
1

Resolved

Unhandled Exception in OnWlanNotification

description

This is a Low priority issues as it only happens after my code has been running most of the day.
In the Wlan.WlanNotificationCodeAcm.ScanFail case the following line fails on occasion
int expectedSize = Marshal.SizeOf(typeof (Wlan.WlanReasonCode));
With something Like it cannot find the size of the unmanaged code. I will update with an exact error the next time it happens

comments

SkiGeek wrote Oct 6, 2009 at 6:21 PM

Here is the error
Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.

It seems to happen on occasion when the computer resumes from standby.
I am creating an application that runs in the background and monitors the internet connection and reconnects when disconnected and logins to a gateway redirect page. (The host bumps you off fairly often) On Vista OS this requires you to disconnect and reconnect the WiFi.

ikonst wrote Nov 19, 2009 at 1:35 PM

A few lines later I'm performing Marshal.ReadInt32, so I guess replacing the problematic line with:
int expectedSize = Marshal.SizeOf(typeof (int));
will only serve it justice.

I've committed this to SVN, but haven't yet tested it.
I should get some PC with a WiFi adapter to test the library (since nowadays, my PC is a Mac).

ikonst wrote Nov 19, 2009 at 1:35 PM

A few lines later I'm performing Marshal.ReadInt32, so I guess replacing the problematic line with:
int expectedSize = Marshal.SizeOf(typeof (int));
will only serve it justice.

I've committed this to SVN, but haven't yet tested it.
I should get some PC with a WiFi adapter to test the library (since nowadays, my PC is a Mac).

wrote Nov 19, 2009 at 1:41 PM

Fixed on changeset 41381

wrote Nov 19, 2009 at 1:41 PM

wrote Feb 22, 2013 at 12:44 AM

Cerilia wrote Mar 13, 2013 at 3:21 PM

I've been writing an application that disables/enables the wireless adapter and afterward it checks RSSI. I've been able to trigger this exception fairly quickly. Changing the line to typeof (int) does fix the issue.

wrote May 16, 2013 at 12:23 PM

wrote May 16, 2013 at 12:23 PM

wrote Jun 14, 2013 at 8:29 AM

B_of_NC wrote Aug 28, 2014 at 4:43 PM

I have downloaded and compiled the latest source code but dispose is not available. When will the patch be applied to the project?

Thanks for the hard work.

B_of_NC wrote Aug 28, 2014 at 4:44 PM

Sorry... disregard the last post as it was posted on the wrong work item.

MicheleR wrote Mar 16, 2015 at 9:56 AM

I am using Managed Wifi 1.1.0 in a vbnet project.
The package has been installed with Nuget.

I suffer from this error when the wlan interface is re-enabled. Unfortunately, it seems from the previous comment that this problem should be fixed in the current version.

May I ask you some help?

urosk wrote Apr 23, 2015 at 7:44 AM

I've stumbled upon the same exception when trying to connect to a non-existent SSID. The fix suggested above does the trick, but I prefer the following modification to keep Managed Wifi code consistent:

int expectedSize = Marshal.SizeOf(Enum.GetUnderlyingType(typeof(Wlan.WlanReasonCode)));

Additionaly, one may explicitly define the WlanReasonCode enumeration base type, just to be on the safe side:

public enum WlanReasonCode: int

That's my two cents on the subject.