使用托管wifi连接到特定bssid时出现System.AccessViolationException错误

时间:2014-04-21 19:12:40

标签: c# access-violation wlanapi bssid

我正在尝试使用bssid连接到wifi网络,并且已经通过了所有可用的链接(包括用于managedwifi的codeplex)。我的代码返回以下错误:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at WifiExample.Program.WlanConnect(IntPtr clientHandle, Guid& interfaceGuid, WlanConnectionParameters& connectionParameters, IntPtr pReserved)

有时它也会引发SEHException。

以下是代码段:

try             
{
  WlanConnect(clientHandle, ref guidd, ref cp, IntPtr.Zero); 
} catch(AccessViolationException e) {
  Console.WriteLine();
  Console.WriteLine(e.GetBaseException());
}

这是它调用的功能。它在我调用它的同一文件中声明。

[DllImport("wlanapi.dll")]

    public static extern int WlanConnect(

    [In] IntPtr clientHandle,

    [In] ref System.Guid interfaceGuid,

    [In] ref Wlan.WlanConnectionParameters connectionParameters,

    IntPtr pReserved);

我的代码基于this

我该如何解决这个问题?任何帮助都会很棒!

0 个答案:

没有答案
相关问题