Hello everyone, I have a .netstandard 2.0 project with my DbContext and Repository that i'm use for my databases. But when I reference Entity Framework Core and my Database Project in my Xamarin.Forms project to create my SQLite Database, the project xamarin.android report this following error:
The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'Windows.Foundation.UniversalApiContract.winmd, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Windows.Foundation.UniversalApiContract.winmd.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection
1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection
1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Lighteam.LittleTent.Xamarin.Android
if I delete the "using" of the database project from my App.xaml.cs, the error vanishs
I tried delete bin and obj folders, clean solution, rebuild, move to root and the error persists.
Answers
@Hiroki4505
Windows.Foundation.UniversalApiContract, because is part of Windows SDK. I think you have added a wrong reference. Please try to use the following one:
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore
And please check this blog for more information:
https://blog.xamarin.com/building-android-apps-entity-framework/
I discovered a converter that was referencing Windows.UI.Xaml.Data from my stand alone UWP project, after deleting this reference the solution works great.
Thanks