0

DragonBoard 410c

Windows 10 IoT Core v.10.0.16273.1000

I SSH into the machine and run netcmd /? which results in this error:

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)

That's straight "out of the box."

I realize that this is an insider preview, but that should work, no? I need to connect to enterprise wifi, and this tool is the only way I know to do that.

Is there a quick way to fix that that does not involve waiting for a new build?

Thank you!

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
Naikrovek
  • 171
  • 1
  • 8

2 Answers2

1

For future visitors of this post. netcmd.exe has been deprecated in IOT Core.

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

IOT_NETCMD (Deprecated)

Adds the command-line tool: netcmd.exe, used for configuring network connectivity. Deprecated in Windows 10, version 1803. The netcmd.exe will be removed when updating to version 1803. Use Windows.Devices.WiFi.WiFiAdapter for managing Wifi. See WiFi Connector example.

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

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
SevenN
  • 171
  • 1
  • 5
  • The first link no longer works. Also, you don't really say what the replacement is. Updated second link ??? https://learn.microsoft.com/en-us/windows/iot-core/release-notes/commercial/april2018update – Henk Poley Jul 14 '20 at 13:02
0

NETCMD appears to be broken in 10.0.16xxx (at least up to 16299).

From Microsoft.

I've resorted to using code similar to the WiFiConnect sample.

In BackgroundTask Timer:

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

In my 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;
 }
awsnap
  • 13
  • 9
  • Yes, the WiFiConnect example shows how to do it, and this method won't work in a background application, which means you can't really use this method on a headless device. It's a workaround for headed devices, yes. – Naikrovek Dec 08 '17 at 15:37
  • It absolutely does if you know the SSID. It's not quite as straight forward in how to but I do it though. If you are trying to use it as a 'WiFi network picker' that would be hard but as a 'WiFi Connector' there are no issues. – awsnap Dec 08 '17 at 19:23
  • Why in the world do you run that as a background **timer**? Just run it as a background application, that way you're not a slave to the timer firing. Anyway, your solution doesn't work for me either. I need netcmd.exe fixed. – Naikrovek Dec 11 '17 at 12:36
  • I can't troubleshoot "it doesn't work for me" so you're on your own there but it works wonderfully for me. I guess you can go pout in the corner and wait for Microsoft if you don't want my help... As far as the timer, because the rest of my application is run inside of the timer. The only time I need to be sure of a WiFi connection is when that is triggered. You could of course use it anywhere/anyway you want. – awsnap Dec 11 '17 at 15:49
  • Thanks for the snarky answer. I appreciate it. I wasn't asking for your help when I said "it doesn't work for me." I was saying "it doesn't work for me" and that's all I was saying. If I was asking for help, I would have actually asked for your help. – Naikrovek Dec 11 '17 at 17:15