Download, extract, and load the sample solution in Visual Studio 15.7.2.
AndroidEFCore21Soln.zip
Build and run the project.
The project should build and run.
The project won't build. The build fails with the following error:
1>C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuildXamarinAndroidXamarin.Android.Common.targets(1590,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Perhaps it doesn't exist in the Mono for Android profile?
EF Core v2.1 or one of its dependencies in turn depends on package System.Memory v4.5.0, while the build appears to be trying to link the app with v4.0.1.0 of the System.Memory assembly.
The previous release of EF Core, v2.0.3, could be included in a Xamarin.Android project without causing this problem. If you change the sample solution to refer to package Microsoft.EntityFrameworkCore.Sqlite v2.0.3 instead of v2.1, the project builds and the app runs as expected.
Microsoft Visual Studio Community 2017
Version 15.7.2
VisualStudio.15.Release/15.7.2+27703.2018
Microsoft .NET Framework
Version 4.7.02556
Installed Version: Community
Visual C++ 2017 00369-60000-00001-AA398
Microsoft Visual C++ 2017
Add New File 3.5
The fastest and easiest way to add new files to any project - including files that start with a dot
Application Insights Tools for Visual Studio Package 8.12.10405.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.40511.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 15.7.31476
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2012 4.0.21208.0
For additional information, visit https://www.asp.net/
ASP.NET Web Frameworks and Tools 2017 5.2.60419.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.0.40424.0
Azure App Service Tools v3.0.0
C# Tools 2.8.2-beta6-62916-08. Commit Hash: 2ad4aabc7a9dada097e54e544ebba48ab1c05074
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
CodeMaid 10.4.53
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
JavaScript Language Service 2.0
JavaScript Language Service
JavaScript Project System 2.0
JavaScript Project System
JavaScript UWP Project System 2.0
JavaScript UWP Project System
JetBrains ReSharper Ultimate 2017.2.2 Build 109.0.20171006.122324
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright 漏 2018 JetBrains, Inc.
Merq 1.1.19-rc (a4ffc1b)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.
Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.
Node.js Tools 1.4.11027.3
Adds support for developing and debugging Node.js apps in Visual Studio
NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
Open Command Line 2.1.179
Opens a command line at the root of the project. Support for all consoles such as CMD, PowerShell, Bash etc. Provides syntax highlighting, Intellisense and execution of .cmd and .bat files.
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info
Search in Velocity by Silverlake Software LLC 0.7.1
Provides a command to search in Velocity the offline documentation and docset viewer for Windows
SQL Server Data Tools 15.1.61804.210
Microsoft SQL Server Data Tools
SQLite & SQL Server Compact Toolbox 4.7
SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections.
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
TypeScript Tools 15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 2.8.2-beta6-62916-08. Commit Hash: 2ad4aabc7a9dada097e54e544ebba48ab1c05074
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.1 for F# 4.1 15.7.0.0. Commit Hash: 56f97a8dd4353d897336941f3e644423b87c794f.
Microsoft Visual F# Tools 10.1 for F# 4.1
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for Universal Windows Apps 15.0.27703.2018
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
VSColorOutput 2.5.1
Color output for build and debug windows - http://mike-ward.net/vscoloroutput
Windows Machine Learning Generator Extension 1.0
Windows Machine Learning Visual Studio Extension Detailed Info
Xamarin 4.10.0.448 (4373404db)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.12.270 (82d750d12)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 8.3.0.19 (HEAD/342b2ce96)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 11.10.1.178 (408d357)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
1>------ Build started: Project: AndroidEFCore21, Configuration: Debug Any CPU ------
1> AndroidEFCore21 -> D:\Projects\AndroidEFCore21Soln\AndroidEFCore21\bin\Debug\AndroidEFCore21.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Perhaps it doesn't exist in the Mono for Android profile?
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : File name: 'System.Memory.dll'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
Projects build report:
Status | Project [Config|platform]
-----------|---------------------------------------------------------------------------------------------------
Failed | AndroidEFCore21\AndroidEFCore21.csproj [Debug|Any CPU]
Time Elapsed 00:00:07.753
adb logcat output is not applicable as the app didn't even build.
FWIW, earlier I had filed a similar issue for Xamarin.iOS: iOS app build fails when referencing package (e.g. Entity Framework Core 2.1) that depends on newer System.Memory.
In 15.7.3 we added a facade for new System.Memory. That should fix this issue. See the following PR:
https://github.com/xamarin/xamarin-android/pull/1509
You can additionally use the Jenkins 15.7 build for a current workaround:
https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-d15-7/
Note: 15.7.3 just went live. Feel free to update and try it out.
@cwrea I can confirm that your sample project compiles on 15.7.3. Please let me know if you encounter the same.
@JonDouglas it seems that https://github.com/dotnet/corefx/issues/29847 is being considered for patch .NET Core 2.1.1 with the purpose of addressing issue with System.Memory on Xamarin.
Just to be sure, is that independent of https://github.com/xamarin/xamarin-android/pull/1509? Are these changes being coordinated?
@divega I believe the difference is that #1509 adds the facade assemblies that will start being "ignored" once Mono removes the respective placeholders described in https://github.com/dotnet/corefx/issues/29847
I will defer to @jonpryor to correct me and answer the question on upstream coordination.
@JonDouglas I just updated to 15.7.3 and re-tested the sample project. I can also confirm it is working now. Thank you!
(FWIW, the similar iOS issue I opened still needs its own fix. 15.7.3 didn't change the Xamarin.iOS behaviour.)
I'm closing this issue based on confirmation from @cwrea. Please feel free to open a new issue if anything comes up.
I downloaded and compiled the sample : AndroidEFCore21Soln.zip using (PC) vs 2017 v15.8.4, Microsoft.EntityFrameworkCoe.Sqlite v2.1.3, Xamarin.Android.Support.Design v27.0.2.1. I got the following error:
Error Can not resolve reference: System.Buffers, referenced by System.Memory. Please add a NuGet package or assembly reference for System.Buffers, or remove the reference to System.Memory. AndroidEFCore21
@davefxy
It seems that Microsoft.Extensions.Caching.Memory > Microsoft.Extensions.Caching.Abstractions > Microsoft.Extensions.Primitives > System.Memory > System.Buffers is resolving a 4.4 version instead of 4.5 and thus you may have to manually install https://www.nuget.org/packages/System.Buffers/ 4.5 to your project.
Successfully installed 'System.Memory 4.5.1' to AndroidEFCore21
Successfully installed 'System.Buffers 4.4.0' to AndroidEFCore21
Checking compatibility for System.Buffers 4.4.0 with MonoAndroid,Version=v8.1.
I believe this is a separate issue from this this thread. Can you file a new issue in our repo?
Thanks!
You are correct. Your solution worked. I had previously tried this but was not able to locate system.buffers because I probably misspelled it.
Thank you very much