【问题标题】:netcmd.exe errors out on fresh image of IoT Core在 IoT Core 的新映像上出现 netcmd.exe 错误
【发布时间】:2017-08-28 17:54:24
【问题描述】:

DragonBoard 410c

Windows 10 IoT 核心版 v.10.0.16273.1000

我 SSH 进入机器并运行 netcmd /? 导致此错误:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.0.21.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

这是直接“开箱即用”。

我知道这是一个内部预览,但这应该可以,不是吗?我需要连接到企业 wifi,而这个工具是我知道的唯一方法。

是否有无需等待新构建的快速解决方法?

谢谢!

【问题讨论】:

    标签: windows-10-iot-core dragonboard


    【解决方案1】:

    对于这篇文章的未来访问者。 netcmd.exe 已在 IOT Core 中弃用。

    Microsoft Hardware Dev Center IoT Core Feature List (10/15/2018)

    IOT_NETCMD(已弃用)

    添加命令行工具:netcmd.exe,用于配置网络 连接性。在 Windows 10 版本 1803 中已弃用。 netcmd.exe 更新到版本 1803 时将被删除。使用 Windows.Devices.WiFi.WiFiAdapter 用于管理 Wifi。见WiFi Connector 例子。

    https://docs.microsoft.com/en-us/windows/iot-core/release-notes/currentcommercial

    【讨论】:

    【解决方案2】:

    NETCMD 似乎在 10.0.16xxx 中被破坏(至少到 16299)。

    来自Microsoft

    我使用了类似于 WiFiConnect 示例的代码。

    在后台任务计时器中:

    if (!(wifi.IsConnected("WIRELESS_SSID")))
    {
       await wifi.WiFiReconnect();
    }
    

    在我的 WiFi.cs 中:

    public async Task InitWiFi()
    {
        // Request access to WiFiAdapter
        WiFiAccessStatus access = await WiFiAdapter.RequestAccessAsync();
    
        var result = await DeviceInformation.FindAllAsync(WiFiAdapter.GetDeviceSelector()).AsTask();
        if (result.Count >= 1)
        {
             firstAdapter = await WiFiAdapter.FromIdAsync(result[0].Id);
    
             await firstAdapter.ScanAsync();
             ssid= firstAdapter.NetworkReport.AvailableNetworks.Where(y => y.Ssid == "YOUR_SSID").FirstOrDefault();
        }
    
    }
    
    public bool IsConnected(string network)
    {
        string profileName = GetCurrentWifiNetwork();
        if (!String.IsNullOrEmpty(profileName) && (network == profileName))
        {
            return true;
        }
        return false;
    }
    
    public async Task<Boolean> WiFiReconnect()
    {
          Task<WiFiConnectionResult> didConnect = null;
          WiFiConnectionResult result = null;
          WiFiReconnectionKind autoConnect = WiFiReconnectionKind.Automatic;
          var credential = new PasswordCredential("DOMAIN", USERNAME, "PASSWORD");
          didConnect = firstAdapter.ConnectAsync(ssid, autoConnect, credential).AsTask();
          result = await didConnect;
          if (result.ConnectionStatus == WiFiConnectionStatus.Success)
          {
               return true;
          }
          else
          {
               return false;
          }
     }
    
    private string GetCurrentWifiNetwork()
    {
          var connectionProfiles = NetworkInformation.GetConnectionProfiles();
          if (connectionProfiles.Count < 1)
          {
               return null;
          }
          var validProfiles = connectionProfiles.Where(profile =>
          {
               return (profile.IsWlanConnectionProfile && profile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.None);
          });
          if (validProfiles.Count() < 1)
          {
               return null;
          }
          ConnectionProfile firstProfile = validProfiles.First();
          return firstProfile.ProfileName;
     }
    

    【讨论】:

    • 是的,WiFiConnect 示例展示了如何执行此操作,并且此方法在后台应用程序中不起作用,这意味着您无法在无头设备上真正使用此方法。这是有头设备的解决方法,是的。
    • 如果您知道 SSID,绝对可以。如何做到这一点并不那么直截了当,但我还是这样做了。如果您尝试将其用作“WiFi 网络选择器”,这会很困难,但用作“WiFi 连接器”则没有问题。
    • 你到底为什么将它作为后台运行计时器?只需将其作为后台应用程序运行,这样您就不会成为计时器触发的奴隶。无论如何,您的解决方案也对我不起作用。我需要修复 netcmd.exe。
    • 我无法解决“它对我不起作用”的问题,所以你自己在那里,但它对我来说非常有用。我想如果你不想要我的帮助,你可以在角落里撅嘴等微软……至于计时器,因为我的应用程序的其余部分是在计时器内运行的。我唯一需要确定 WiFi 连接的时间是触发它的时间。你当然可以在任何地方/任何你想要的地方使用它。
    • 感谢您的尖刻回答。我很感激。当我说“这对我不起作用”时,我并不是在寻求你的帮助。我在说“它对我不起作用”,这就是我所说的。如果我在寻求帮助,我实际上会寻求你的帮助。
    猜你喜欢
    • 1970-01-01
    • 2019-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 2018-02-16
    • 1970-01-01
    相关资源
    最近更新 更多