2

我正在尝试使用 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);

我的代码基于

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

4

0 回答 0