Type Native Wifi.Wlan + WlanReasonCode cannot be marshaled error

£可爱£侵袭症+ 提交于 2019-12-02 02:41:43

I think I may have fixed the problem, but Im not sure what will be the effects of it.

I am using Managed Wifi API and within the WlanAPI.cs, there is a line of code that checks for the size of the return code. This is the line:

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

what I did find out was that when the Reason code is "Success", it has an enumerated value of 0. So I commented the line and added zero in the next line as such:

                            //int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanReasonCode));
                            //if (notifyData.dataSize >= expectedSize)
                            //{
                            //    Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode) Marshal.ReadInt32(notifyData.dataPtr);
                            //    if (wlanIface != null)
                            //        wlanIface.OnWlanReason(notifyData, reasonCode);
                            //}

to

//int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanReasonCode));
                            if (notifyData.dataSize >= 0)
                            {
                                Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr);
                                if (wlanIface != null)
                                    wlanIface.OnWlanReason(notifyData, reasonCode);
                            }

this seems to work, but Im not sure if I opened a can of worms. Can you guys think of any other better solution?

Thanks, Mat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!