Bug 40782 - Confusing and inaccurate "Please file a bug report ... Could not load assembly" error message if any library referenced from a Xamarin.Android app project fails to build
Summary: Confusing and inaccurate "Please file a bug report ... Could not load assembl...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 7.0 (C8)
Hardware: PC Windows
: Normal normal
Target Milestone: master
Assignee: dean.ellis
URL:
: 28870 36936 37922 38252 39793 40457 41028 42165 42484 42497 42923 43085 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-04-29 19:20 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2017-03-21 20:21 UTC (History)
16 users (show)

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

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 for Bug 40782 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:20:11 UTC
Confusing and inaccurate "Please file a bug report ... Could not load assembly" error message if any library referenced from a Xamarin.Android app project fails to build




## Regression status: not a recent regression

This happens on older versions of Xamarin dating back a long ways.




## Steps to replicate

1. Create a new "Visual C# > Android > Blank App (Android)" project in Visual Studio.

2. Add a "Visual C# > Android > Class Library (Android)" project to the solution.

3. Introduce a C# syntax error in the class library, for example by removing a closing curly brace "}".

4. Add a reference to the class library in the Android app project.

5. Build the Android app project.




## Results

The build produces 2 errors. One is the _expected_ syntax error from the class library project, but the other _bad_ error is a confusingly worded error message from the app project:

> Error		Unexpected error - Please file a bug report at
> http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException:
> Could not load assembly 'ClassLibrary1, Version=, Culture=neutral,
> PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android
> profile?




## Expected results

The standard error for this situation (as demonstrated for example by both Xamarin.iOS projects and Windows console C# apps) is:

> Error		Metadata file
> 'c:\source\ConsoleApplication1\ClassLibrary1\bin\Debug\ClassLibrary1.dll'
> could not be found


Xamarin.Android should produce the same error, and it should certainly _not_ instruct users to file a bug for this error. This scenario is _expected_ to produce a build error.
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:23:11 UTC
*** Bug 36936 has been marked as a duplicate of this bug. ***
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:38:50 UTC
*** Bug 37922 has been marked as a duplicate of this bug. ***
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:41:49 UTC
*** Bug 38252 has been marked as a duplicate of this bug. ***
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:43:55 UTC
*** Bug 39793 has been marked as a duplicate of this bug. ***
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:52:11 UTC
*** Bug 40457 has been marked as a duplicate of this bug. ***
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 20:41:07 UTC
## Results on XamarinVS 4.2.0.21 (a532c82)

The error message has changed slightly in the new Alpha version. It no longer mentions filing a bug report, which is good, but it is still inconsistent with the "Metadata file... could not be found" error message that is expected for this situation based on the standard behavior of other C# app types.


### New error message in 4.2.0

> Error		The "ResolveLibraryProjectImports" task failed unexpectedly.
> System.IO.FileNotFoundException: Could not load assembly 'ClassLibrary1, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
> File name: 'ClassLibrary1.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()
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 21:31:04 UTC
*** Bug 28870 has been marked as a duplicate of this bug. ***
Comment 11 Brendan Zagaeski (Xamarin Team, assistant) 2016-07-19 15:44:04 UTC
*** Bug 42484 has been marked as a duplicate of this bug. ***
Comment 12 Brendan Zagaeski (Xamarin Team, assistant) 2016-07-19 15:44:36 UTC
*** Bug 42165 has been marked as a duplicate of this bug. ***
Comment 13 Brendan Zagaeski (Xamarin Team, assistant) 2016-07-19 15:52:05 UTC
*** Bug 42497 has been marked as a duplicate of this bug. ***
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2016-07-19 16:04:21 UTC
*** Bug 41028 has been marked as a duplicate of this bug. ***
Comment 16 Jonathan Pryor 2016-07-29 21:17:36 UTC
*** Bug 42923 has been marked as a duplicate of this bug. ***
Comment 17 Jonathan Pryor 2016-08-19 16:14:29 UTC
*** Bug 43085 has been marked as a duplicate of this bug. ***