Win32Expection

Mar 22, 2009 at 10:03 AM
Hi

I tried running the example on a Vista gold and I get a Win32Exception "The request is not supported" when executing this function
Wlan.ThrowIfError(Wlan.WlanGetAvailableNetworkList(client.clientHandle, info.interfaceGuid, flags, IntPtr.Zero, out availNetListPtr));

What's wrong here or how can i solve this error?

Thanks for your help appreciated
Mar 30, 2009 at 10:17 PM
So any ideas on why this is happening?
Mar 31, 2009 at 6:17 PM

Hi mrabie,

You have to call the function in the following way. This is working code and you can try it.

Wlan.WlanAvailableNetwork[] availableList;

            Wlan.WlanInterface _adapter;

            WlanClient _wlanClient = new WlanClient();

            if (_wlanClient.Interfaces.GetLength(0) > 0)

            {

                foreach (WlanClient.WlanInterface Interface in _wlanClient.Interfaces)

                {

                    _adapter = Interface; // if you more than one wifi card, then you need to check te required one for scanning.

                    break;

 

                }

            }

           

            availableList = _adapter.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles);

-Raj

From: mrabie [mailto:notifications@codeplex.com]
Sent: Monday, March 30, 2009 2:18 PM
To: Rajashekar Gunari
Subject: Re: Win32Expection [managedwifi:50877]

From: mrabie

So any ideas on why this is happening?

Read the full discussion online.

To add a post to this discussion, reply to this email (managedwifi@discussions.codeplex.com)

To start a new discussion for this project, email managedwifi@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Mar 31, 2009 at 7:09 PM
Hi,

Thanks Raj for the reply.  But 
Wlan.WlanInterface _adapter;
gives 
Error 1 The type name 'WlanInterface' does not exist in the type 'NativeWifi.Wlan' C:\Users\mrabie\Documents\Downloads\WPF\managedwifi-17201\WlanApi.cs 278 22 ManagedWifi

is this statement correct, or do i use 
WlanClient.WlanInterface _adapter;

also 
availableList = _adapter.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles); 
gives 
Error 2 Use of unassigned local variable '_adapter' C:\Users\mrabie\Documents\Downloads\WPF\managedwifi-17201\WlanApi.cs 300 33 ManagedWifi
since it's initialized in the if statement.

Thanks for your help
Mustafa

Mar 31, 2009 at 7:19 PM

Try the following code

void GetNetworks()

        {

            Wlan.WlanAvailableNetwork[] availableList;

            WlanClient.WlanInterface _adapter = null;

            WlanClient _wlanClient = new WlanClient();

            if (_wlanClient.Interfaces.GetLength(0) > 0)

            {

                foreach (WlanClient.WlanInterface Interface in _wlanClient.Interfaces)

                {

                    _adapter = Interface; // if you more than one wifi card, then you need to check te required one for scanning.

                    break;

                }

            }

            availableList = _adapter.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles);

        }

From: mrabie [mailto:notifications@codeplex.com]
Sent: Tuesday, March 31, 2009 11:10 AM
To: Rajashekar Gunari
Subject: Re: Win32Expection [managedwifi:50877]

From: mrabie

Hi,

Thanks Raj for the reply. But

Wlan.WlanInterface _adapter;

gives

Error 1     The type name 'WlanInterface' does not exist in the type 'NativeWifi.Wlan'      C:\Users\mrabie\Documents\Downloads\WPF\managedwifi-17201\WlanApi.cs    278   22      ManagedWifi

is this statement correct, or do i use

WlanClient.WlanInterface _adapter;

also

availableList = _adapter.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles);

gives

Error 2     Use of unassigned local variable '_adapter'      C:\Users\mrabie\Documents\Downloads\WPF\managedwifi-17201\WlanApi.cs    300   33      ManagedWifi

since it's initialized in the if statement.

Thanks for your help

Mustafa

Read the full discussion online.

To add a post to this discussion, reply to this email (managedwifi@discussions.codeplex.com)

To start a new discussion for this project, email managedwifi@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Mar 31, 2009 at 7:31 PM
thanks agin for the prompt reply,

I tried the code segment you provided but i still get the same error "not supported", in the WlanApi.cs

In the WlanClient() i changed it to 
Wlan.ThrowIfError(Wlan.WlanOpenHandle(Wlan.WLAN_CLIENT_VERSION_LONGHORN, IntPtr.Zero, out negotiatedVersion, out clientHandle));

since i am using vista and not XP.

Shouldn't this problem doesn't show in the WlanApi?
Apr 1, 2009 at 1:44 AM
Can you send me a working example for the apis?  I would really appreciate it

thanks
Apr 1, 2009 at 2:05 AM

Mrabie,

The code I have sent is working fine in XP and Vista.

-Raj

From: mrabie [mailto:notifications@codeplex.com]
Sent: Tuesday, March 31, 2009 5:44 PM
To: Rajashekar Gunari
Subject: Re: Win32Expection [managedwifi:50877]

From: mrabie

Can you send me a working example for the apis? I would really appreciate it

thanks

Read the full discussion online.

To add a post to this discussion, reply to this email (managedwifi@discussions.codeplex.com)

To start a new discussion for this project, email managedwifi@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 1, 2009 at 9:31 AM
I tried it and I got the errors in the previous posts.  Is this code to be used from inside my app right?  I created a windows form and called the function you sent me from the button_click(), it gave me and error of "too many handels open for the server" when creating a new WlanClient.

Do i need to have Vista SP1 or doesn't matter? I am currently running Vista Gold

Thanks a million