I was trying to migrate my solution of NET CORE 1.1 to NET CORE 2.0 as a linux server.
When I run dotnet xxx.DLL in Ubuntu 14.04 x64 the following problem occurs:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.AspNetCore.Hosting.WebHostBuilder..ctor()
at Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(String[] args)
at Teste.Program.BuildWebHost(String[] args).
Follow some configurations of my project:
Project.csproj
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win10-x64;ubuntu.14.04-x64</RuntimeIdentifiers>
I tried to place the missing package in Nuget and the same thing did not work.
Linux server owns NET CORE 2.
Updated VS 2017 (15.3.2)
I checked if the DLL was on the server (and it was).
I tried to place the tag:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Does anyone have a suggestion?
I made a lot of tests simple. I created a MVC NET CORE 2.0 project and I did not do anything. I compiled for Ubuntu 14.04 and when I try to run it. A similar error occurs:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.IO.FileSystem, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Test.Program.BuildWebHost(String[] args)
Is there any problem as the MVC CORE 2 solution in the 14.04 x64 linux server?
/cc @Eilon
@galodoido794 , what ASP.NET packages are you referencing? If they are still the 1.X packages, that may be the cause.
I tried to migrate, but as I gave error I'm doing a simpler test. I've created a new project (CORE 2.0) for test. All packages are NET CORE 2.0.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win10-x64;ubuntu.14.04-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
I posted an image of the project on this [link] (http://imgur.com/a/9KvB1)
When publishing in Ubuntu 14.04 gives the following error:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.IO.FileSystem, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Test.Program.BuildWebHost(String[] args)
On this server I have an ASP NET CORE 1.1 application worked. I have already upgraded the server to Asp NET CORE 2.0.
@galodoido794 how are you publishing your application? Are you making use of the command line option "dotnet publish" or are you using VS (folder profile) to publish?
I compile the application on Windows and copy the DLLS to Linux.
In my NET CORE 1.1 application (which works) I use the same command I tried for the new NET CORE 2.0 application;
dotnet publish -c release -r ubuntu.14.04-x64
OK. I had a similar issue publishing for ubuntu.16.04-x64 which turned out to be a msbuild issue (see https://github.com/dotnet/corefx/issues/23436 and https://github.com/dotnet/sdk/issues/1502) . I can, however, get around it by using "dotnet publish". But if that doesn't work for you then I'm not sure what is going on.
@ericstj in case he has any ideas.
Yes, as @onematchfox mentioned this is likely https://github.com/dotnet/sdk/issues/1502. You'll hit it if you ever publish from VS or msbuild.exe on windows for a non-Windows RID when old packages are in the graph. If you use dotnet publish (to a new folder) you shouldn't hit it. If you are hitting it while using dotnet publish and you have a clean publish folder then I'd like to see a log dotnet publish -c release -r ubuntu.14.04-x64 /flp:v=diag
I will read the articles and test those possibilities later.
Using the _dotnet publish -c release -r ubuntu.14.04-x64 /flp:v=diag_ command generated the following error:
Microsoft.Win32.Registry, Version = 4.1.0.0 -> System.BadImageFormatException: Can not load a reference assembly for execution.
At Microsoft.AspNetCore.DataProtection, KeyManagement.XmlKeyManager.GetFallbackKeyRepositoryEncryptorPair ()
And I noticed that in the build it generates many conflicts:
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.io\4.3.0\ref\netstandard1.5\System.IO.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.dll' because AssemblyVersion '4.2.0.0' is greater than '4.1.0.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.Compression.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.io.compression\4.3.0\ref\netstandard1.3\System.IO.Compression.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.Compression.dll' because AssemblyVersion '4.2.0.0' is greater than '4.1.1.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.FileSystem.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.io.filesystem\4.3.0\ref\netstandard1.3\System.IO.FileSystem.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.FileSystem.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.1.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.FileSystem.Primitives.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.io.filesystem.primitives\4.3.0\ref\netstandard1.3\System.IO.FileSystem.Primitives.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.IO.FileSystem.Primitives.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.1.0'.
1> Encountered conflict between 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.4.0\lib\netstandard2.0\Microsoft.Win32.Registry.dll' and 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.4.0\runtimes\unix\lib\netcoreapp2.0\Microsoft.Win32.Registry.dll'. Could not determine winner due to equal file and assembly versions.
1> Encountered conflict between 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.4.0\lib\netstandard2.0\Microsoft.Win32.Registry.dll' and 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.4.0\runtimes\win\lib\netcoreapp2.0\Microsoft.Win32.Registry.dll'. Could not determine winner due to equal file and assembly versions.
1> Encountered conflict between 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\runtime.debian.8-x64.runtime.native.system.security.cryptography.openssl\4.3.0\runtimes\debian.8-x64\native\System.Security.Cryptography.Native.OpenSsl.so' and 'Runtime:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\runtime.fedora.23-x64.runtime.native.system.security.cryptography.openssl\4.3.0\runtimes\fedora.23-x64\native\System.Security.Cryptography.Native.OpenSsl.so'. Could not determine winner due to equal file and assembly versions.
I did not have time to see all the articles to test other solutions, but I'll keep trying later.
I tested some possibilities and I did not succeed. I did the same process I do in NET CORE 1.1. Compile on windows and copy the files to Ubuntu 14.04 x64 and it works. NET CORE 2.0 does not work. I tested publishing with MSBuild and with dotnet publish -c release -r ubuntu.14.04-x64 /flp: v = diag.
Will only I have a problem with ASP CORE 2.0 on ubuntu 14.04? To test it is very simple, create a CORE 2.0 MVC project (simple) and try to publish it in ubuntu. In my case the error now is: Microsoft.Win32.Registry, Version = 4.1.0.0 Can not load a reference assembly for execution.
@galodoido794 got exactly the same problem with .NET Core 2.0.0 runtime:
Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.0.0
...
...and so forth
And similarly to you my project works fine with .NET Core 1.1.2 runtime (LTS).
p/s Just in case, I use Windows Server 2012.
Not sure if this is related, but I just got this error trying to run a project inside visual studio on windows:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Apparently I had opened the folder containing the folder with the solution (.sln) file. It seemed I was inside the solution, intellisense was fine, but right clicking on the folders did not bring the usual options like clean/build solution. Although F5 worked to debug it, but it gave this error.
@bogdan-st , probably not related. Do you want to open a new issue in the dotnet/cli with more details of how your project is configured?
@galodoido794 are you still blocked on this? Have you tried dotnet publish -c release -r linux-x64 with a .NET Core 2.0 application?
I have not tried with the new patch from Visual Studio 15.4 or this does not solve this problem?
I've tried compiling anyway and I could not get it to work.
@galodoido794 it sounds like you have a small isolated repro. Can you zip that up and attach it to the bug (deleting the bin and obj folder, and providing the repro steps)? I'll have a look at why you're getting the reference-assembly error.
I did the following steps:
In linux:
apt-get update
apt-get upgrade
I installed the new Visual Studio 15.4.0
Run the command: dotnet publish -c release -r ubuntu.14.04-x64
And it worked.
@bogdan-st What did you do to fix it? I have the same error.
I'm seeing the same problem with a blank asp.net core application project as well.
Steps:
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers> into a PropertyGroupIt fails with
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.AspNetCore.Hosting.WebHostBuilder..ctor()
at Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(String[] args)
at WebApplication1.Program.BuildWebHost(String[] args)
at WebApplication1.Program.Main(String[] args)
Aborted
However, if I run dotnet publish -c release -r ubuntu.16.04-x64, and copy the result publish folder into that same machine. it works fine. The difference seems to be that System.Runtime.Extension is 4.1.1 in the failing case (when publish from VS) and 4.2.0 when publishing from command line.
Looks like this is a bug in VS tooling.
@ericstj @Petermarcu FYI
I believe that this is https://github.com/dotnet/sdk/issues/1502.
Thanks. That looks like it. I'm closing this issue now.