当前位置: 代码迷 >> C# >> 使用 NetworkInterface.GetAllNetworkInterfaces()后,打开设计器报:内存位置访问无效,该如何解决
  详细解决方案

使用 NetworkInterface.GetAllNetworkInterfaces()后,打开设计器报:内存位置访问无效,该如何解决

热度:147   发布时间:2016-05-05 03:59:59.0
使用 NetworkInterface.GetAllNetworkInterfaces()后,打开设计器报:内存位置访问无效
以下是我获取适配器代码,winform,VS2012
            var nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (var ni in nics)
            {
                IPInterfaceProperties property = ni.GetIPProperties();
                foreach (UnicastIPAddressInformation ip in property.UnicastAddresses)
                {
                    if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        DicAllIPV4List.Add(ni.Name, ip.Address.ToString());
                    }
                }
            }

但使用后,编译正确,但打开设计器报:内存位置访问无效,求大神

------解决思路----------------------
别把代码写进Designer里