Getting IP-Address in Win 10 IoT Core

I was working on a new pet project for Windows 10 IoT Core.

At this moment Win10 IoT Core is not supporting the Wi-pi Wi-Fi dongle. So I am using a Dlink 505 mobile companion to attach my Raspberry Pi b2 to my local network. This works great although Visual Studio has some trouble detecting the device.

But because the default app (yes, this is just an app) on the Pi shows the current IP-address, I can simply submit that address when deploying (in the project settings).


So far so good.

But when I deployed my own app I ran into a little problem. My Pi gets the current IP-address dynamically so at one point my deployment was not working anymore. The device had a new IP-address….

And this address is also needed for RDP so it is rather important.

I wanted to read the current IP address in C# code so I could show it in my own app. This seems a bit trivial, but Google was not helping me this time. All examples were based on System.Net so that was not working.

Then I was thinking, could it be that the default app is just open sourced? That way I could look in the code MSFT provided.

And yes it is! Just go to the github location.

And there I found the code to read the IP4 address (now a bit modified):

public static string GetCurrentIpv4Address()
  var icp = NetworkInformation.GetInternetConnectionProfile();
  if (icp != null
        && icp.NetworkAdapter != null
        && icp.NetworkAdapter.NetworkAdapterId != null)
    var name = icp.ProfileName;

    var hostnames = NetworkInformation.GetHostNames();

    foreach (var hn in hostnames)
      if (hn.IPInformation != null
          && hn.IPInformation.NetworkAdapter != null
          && hn.IPInformation.NetworkAdapter.NetworkAdapterId
                                                     != null
          && hn.IPInformation.NetworkAdapter.NetworkAdapterId
                      == icp.NetworkAdapter.NetworkAdapterId
          && hn.Type == HostNameType.Ipv4)
        return hn.CanonicalName;

  return "---";

Resolve the namespaces if needed…

So thank you MSFT for making the code available.


Windows 10 IoT Core Startup App needs the Package name

I was looking for a way to get my own Windows 10 IoT Core app started when my Raspberry Pi2 is rebooted.

Because putting an app on the remote device using VS 2015 is not enough. The normal startup app:


Must be replaced by your own app.

The screen shown is the main screen from the ‘DefaultApp’ running.

I stumbled across which give a pretty good explanation on how to create and deploy an app on a Win 10 Core device. And there is a description on how to get my Pi started up with my app.

The name of my app is App2 btw.

I followed the steps in Powershell. But “iotstartup list App2” gave me nothing. And just “iotstartup list” gave me a list of headed apps, but not my app. I fiddled around (checking head vs. headless etc.) but then it striked me that also the ‘DefaultApp’ was not listed with the exact name:


So I was thinking, maybe ‘App2’ is just plain wrong, I have to use another identifier…

And there it was, in plain sight, the package name:


So I tried ‘iotstartup add headed 7e3ab565-bbac-481a-86c8-12c991747ec2’ and it worked like a charm!

epilogue: after the successful startup, I switched back to the default app and rebooted. But this seemed to force the Pi to reinstall Windows 10 IoT Core again (I was told to relax while the device was starting up with this nice circular waiting cursor). But this took a lot of time! So finally I put a new image on the micro-sd card but then the Pi was not booting anymore. I just got a red and green led running continuously. Did it die on me? Nope. I had another micro-sd card with Raspbian on it and the Pi started and worked fine. Then I tried my Windows 10 IoT Core again and now it rebooted correctly.