Bug 41968 - Can't find library: Windows.Foundation.UniversalApiContract.winmd
Summary: Can't find library: Windows.Foundation.UniversalApiContract.winmd
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-06-18 11:11 UTC by Andeww Brand
Modified: 2017-06-23 19:53 UTC (History)
5 users (show)

Tags: BZCU
Is this bug a regression?: ---
Last known good build:


Attachments
Project file for the droid project (14.77 KB, text/plain)
2016-06-18 11:11 UTC, Andeww Brand
Details
Project file for the PCL project (10.90 KB, text/plain)
2016-06-18 11:25 UTC, Andeww Brand
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Andeww Brand 2016-06-18 11:11:00 UTC
Created attachment 16389 [details]
Project file for the droid project

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1062,2): monodroid error XA0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly 'Windows.Foundation.UniversalApiContract.winmd, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?

The file does seem to exist in on my machine.  Below is a listing.

 Directory of C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0

06/17/2016  09:30 PM    <DIR>          .
06/17/2016  09:30 PM    <DIR>          ..
07/09/2015  07:44 PM         3,616,768 Windows.Foundation.UniversalApiContract.winmd
               1 File(s)      3,616,768 bytes
               2 Dir(s)   3,213,996,032 bytes free


I've attached the project file for the droid project.
Comment 1 Andeww Brand 2016-06-18 11:25:24 UTC
Created attachment 16390 [details]
Project file for the PCL project

Project file for the PCL project.  It contains the reference to the missing library.
Comment 2 Andeww Brand 2016-06-18 12:08:12 UTC
I was able to figure this out:

I added 

using windows.ui.core to some PCL projects.  After I removed those refrences and manually removed the reference form the PCL project file, I was able to build the androad project.  I was able to move the Windows.UI.Core references to a UWP project, so all is good for me.

You may want to check on some usability issues.
1)  Confusing error messages
2)  I should not have been able to add Windows.UI.Core to the PCL if it was not supported on all platforms I specified.
Comment 4 Sylvrec 2017-01-03 15:10:03 UTC
same error :

Severity	Code	Description	Project	File	Line	Suppression State
Error		The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'Windows.Foundation.UniversalApiContract.winmd, Version=, 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, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 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.<ExecuteInstantiatedTask>d__26.MoveNext()	DxCareAppsPhysician.Droid
Comment 5 FlavioSC 2017-03-16 19:59:07 UTC
Got this here:

Severity	Code	Description	Project	File	Line	Suppression State
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, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 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.<ExecuteInstantiatedTask>d__26.MoveNext()	Monitor.Android
Comment 6 John Miller [MSFT] 2017-06-23 19:53:38 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it was solved in Comment #2. 

@Sylvrec @FlavioSC

The ResolveLibraryProjectImports errors posted seem to suggest a similar issue of referencing libraries in an Android project that are not compatible with Xamarin.Android. Could you check and confirm if you have any similar issues like mentioned in comment 0? That is, make sure that no manually added references are present to Windows.* DLLs in a PCL project or the Android project.

If there does seem to be an issue in the Xamarin platform, please summarize in a new bug report with your version information and a diagnostic build log (https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/). Feel free to reference this bug report when you file for additional context.