5

I've installed Ubuntu Core 16.04 on a Raspberry PI 3 and managed to get a .NET Core console app running on it by using the instructions here and using .NET Core version 1.2.0-beta-001291-00 which is compatible with ARM chips.

When I do the same with a basic ASP.NET Core app I get the following error :

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Component.Primitives, Version=4.2.0.0, Cultire=Neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Microsoft.Extensions.FileProviders.PhysicalFileError.CreateFileWatcher(String root) at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize>(IHostingEnvironment hostingEnvironment, String appplicationName, String contentRootPath, WebHostOptions options) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildHostingServices() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Program.Main(String[] args) in /home/freek/aspnetcore/program.cs: line 12 Aborted

Here is the contents of program.cs :

using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

public class Program
{
  public static void Main(string[] args)
  {
    Console.WriteLine("Hello World API!");

    var builder = new ConfigurationBuilder()
      .SetBasePath(Directory.GetCurrentDirectory())
      .AddJsonFile("appsettings.json", optional: true)
      .Build();

    var host = new WebHostBuilder()
      .UseKestrel()
      .UseConfiguration(builder)
      .UseContentRoot(Directory.GetCurrentDirectory())
      .UseStartup<Startup>()
      .Build();

    host.Run();       
  }  
}

The code runs fine on a deskop with Ubuntu running .NET Core 1.1 but gives the error on a PI running .NET Core 1.2.0-beta-001291-00.

2 Answers 2

2

Microsoft has been matching their version numbers for all of their core projects. Most package developers are following suit. So .net core version 1.1.0 most packages that are compatible with that version are also version 1.1.0

You need to update your project dependencies to their beta versions also. If you look at your project.json and go through all the dependencies look them up on nuget.org and get their latest beta version (1.2.0-beta-something) and update the project.json version number to the one you find on nuget.org it may work. It is beta after all.

My recommendation would be to installed .net core 1.1.0 on the Raspberry Pi and then it should work fine. However if you can't do that the above should work.

Sign up to request clarification or add additional context in comments.

2 Comments

.net core 1.2.0-beta-001291-00 is currently the only one that is compatible with arm chips. The project dependencies do not have similar versions so it is impossible at the moment. When the next version of .net core is officially released I will revisit this. I managed to get a TCP server going that does not have dependencies. Thanks for your input.
Now with .net core 2.0 and corresponding sdk you can publish for arm without issues: dotnet publish -c Release -r linux-arm.
0

It is important to publish the solution with the correct Runtime Identifier (RID).

For Raspberry Pi, you should use linux-arm or linux-arm64.

Though dotnet is compatible with most popular platforms, the applications still needs to be either built locally on the machine that should run it, or using the correct RID for the machine that should run.

You cannot just use the same files (.dlls and such) as the ones used on your desktop computer. By default, dotnet publish uses the architecture of the machine it runs on, which is fine in all other cases than when the application needs to run on a different architecture (or OS). Your Pi and your desktop computer uses different architectures.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.