Carsten
Carsten

Reputation: 11596

Why can't I run a basic .NET Core application on a Win10 ARM system?

Currently I am testing some home automation using Windows 10 IoT Core and the new .NET Core libraries. I've setup a vanilla Rasberry PI 2 with the latest stable version of Windows 10 IoT Core (10.0.10586). I've also installed the currently latest (RC2-20221) .NET packages using dnvm, dnvm list displays:

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
   1.0.0-rc1-final   clr     x86          win
   1.0.0-rc1-final   coreclr arm          win
   1.0.0-rc1-final   coreclr x64          win
   1.0.0-rc1-final   coreclr x86          win
   1.0.0-rc1-update2 clr     x86          win             default, dnx-clr-win-x86.1.0.0-rc1-update2
   1.0.0-rc2-20221   clr     x64          win
   1.0.0-rc2-20221   clr     x86          win
   1.0.0-rc2-20221   coreclr arm          win
*  1.0.0-rc2-20221   coreclr x64          win
   1.0.0-rc2-20221   coreclr x86          win

I then created a new console application (.NET Core), which does nothing more than printing a string:

public class Program
{
    public static void Main(string[] args)
    {
        System.Console.WriteLine($"Hello Raspberry {Math.PI}!");
    }
}

I've also updated the project.json file, from which I removed the "type": "platform"-property of the "Microsoft.NETCore.App" dependency. Therefor I've added two runtimes explicitly:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  },

  "runtimes": {
    "win10-x64": {},
    "win10-arm": {}
  }
}

The first runtime (win10-x64) is there to test the application on my development machine, the latter one is for deployment. I am able to successfully build my application using the following command:

dotnet publish --output "X:\Dev\IoT\Samples\Console\output" --runtime win10-arm

Building the project with the runtime parameter win10-x64 within the command line works as expected: I get a full-featured executeable, that prints the desired string to my console. After deploying the win10-arm-build to my Rasberry PI, trying to execute the application from powershell gives me the oddest error I've experienced so far:

Program 'IoT.Samples.Console.exe' failed to run: The operation completed successfully.
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

So the program fails to run, because... well... success?

I followed the instructions here to connect to the RaspPI using Powershell. Also, as expected, running the ARM build from my x64-machine does not work. So obviously the application get's compiled for ARM correctly.

So why does powershell respond with an error? And what does this error tell me?

Thanks in advance!

Upvotes: 2

Views: 2180

Answers (3)

Darxis
Darxis

Reputation: 1570

I got it working on Windows 10 IoT Core RTM 10.0.14393.576 with Raspberry Pi3.

The thing is that you have to launch your .NET Core App using the CoreRun.exe tool, which is available in the CoreCLR.

Firstly you have to build and deploy the CoreCLR to your Windows 10 IoT Core.

  1. Clone the master branch of the dotnet/coreclr repository at https://github.com/dotnet/coreclr.
  2. Build the sources of the CoreCLR, by typing the following command from within the root repository dir: build.cmd release arm. This will build the sources for ARM with the Release configuration. On my machine the build takes approximately half an hour.
  3. After the build is complete, the binaries are available in the bin\Product\Windows_NT.arm.Release directory. Copy this whole directory to your Windows 10 IoT Core (for example to C:\netcore\coreclr).

Now, you have to deploy your .NET Core app to your Windows 10 IoT Core device:

  1. Specify the win10-arm runtime in the project.json file.
  2. Remove the "type": "platform" property of the "Microsoft.NETCore.App" dependency.
  3. dotnet restore
  4. dotnet publish -c Release -r win10-arm (or -c Debug if you want the Debug configuration)
  5. Your app publish package is now available in the bin\Release\netcoreapp1.0\win10-arm\publish directory. Copy this directory to your Windows 10 IoT Core (for example to C:\netcore\apps\MyApp).

Now you have just to run your app, using the CoreRun.exe tool. The most important thing is that you have to specify the DLL file, not the EXE one.

C:\netcore\coreclr\CoreRun.exe "C:\netcore\apps\MyApp\MyApp.dll"

Upvotes: 3

Gavin Fang
Gavin Fang

Reputation: 367

according to https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/ we will get ARM32/64 support in Q4 2016 or Q1 2017

Upvotes: 1

Charles Mager
Charles Mager

Reputation: 26213

If you look around in the GitHub issues relating to CoreCLR for ARM, you'll find recent comments like this one:

dotnet for ARM is in proof of concept quality state. In fact it is completely broken. ;-)

I don't think it's ready yet...

Upvotes: 2

Related Questions