Bug 23210 - Warning from Android targets after opening Xamarin.Forms solution: "Could not load assembly"
Summary: Warning from Android targets after opening Xamarin.Forms solution: "Could not...
Status: RESOLVED DUPLICATE of bug 50914
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.1 (C9)
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL:
: 21987 25309 25369 25686 26001 27297 27587 29685 29832 29868 31135 32807 33314 33662 33748 34749 36306 39907 40647 44169 45398 ()
Depends on:
Blocks:
 
Reported: 2014-09-19 23:52 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-12-27 08:09 UTC (History)
30 users (show)

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


Attachments
Test case (4.57 MB, application/zip)
2014-09-19 23:52 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Screen capture: warning after creating XF project (1.60 MB, application/x-shockwave-flash)
2014-09-19 23:55 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 DUPLICATE of bug 50914

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-09-19 23:52:53 UTC
Created attachment 8132 [details]
Test case

Warning from Android targets after opening Xamarin.Forms solution: "Could not load assembly"


Regression status: regression.

Bad: Xamarin 3.3.47, 3.5.58, and 3.6.245.

Good: Xamarin 3.1.228.0 (2349ba7b70529ea26ba842e1ec32d054bd6abb3b).



## Steps to reproduce

Open the `.sln` file from the attached test case in Visual Studio.

OR

1. Select "File -> New Project".

2. Select "Visual C# -> Mobile Apps -> Blank App (Xamarin.Forms Portable)"

3. Click OK.



## Result

The following warning appears under "View -> Error List".

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



## "Workaround"

Open the `.sln` file with Xamarin 3.1.228 in Visual Studio. This creates a different `.suo` file.

The test case includes a copy of the 3.1.228 `.suo` file in the `SUOFile_3.1.228\` directory. If you copy this `.suo` file into the top level "FormsApp" directory, the warning no longer appears in Xamarin 3.3.47, 3.5.58, or 3.6.245.



## Version information

Microsoft Visual Studio Professional 2013
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.6.245.0 (49abddaaec0a8be4cb890b8cddefed81727bbe6c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.16.0.17 (2a7b68212b17c903160fbd8e0106babb299d1be3)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.0.52.0 (b38baf1c655f9fe816fee25cbd7ac78225def3e9)
Visual Studio extension to enable development for Xamarin.iOS.o

Xamarin.Forms 1.0.6186

Windows 8.1 64-bit
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-19 23:55:31 UTC
Created attachment 8133 [details]
Screen capture: warning after creating XF project
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-19 23:57:45 UTC
*** Bug 21987 has been marked as a duplicate of this bug. ***
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-20 00:07:18 UTC
Bug 21791 is also likely a duplicate.

Bug 22201 looks quite similar too, but that report is about Xamarin Studio on Windows, and in that report the message is marked by the IDE as an Error rather than a Warning.
Comment 4 Rajneesh Kumar 2014-09-22 04:14:31 UTC
I have checked this issue and able to reproduce. To reproduce this issue I have followed the steps mentioned in bug description.

Steps to reproduce:

1. Open Visual Studio
2. Select "File -> New Project".
2. Select "Visual C# -> Mobile Apps -> Blank App (Xamarin.Forms Portable)"
3. Click OK, Observed that project is created
4. You will get the following warning:

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

Screencst: http://www.screencast.com/t/5edc6Urk3IJh

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0444002-02032
Microsoft LightSwitch for Visual Studio 2013

Microsoft Office Developer Tools for Visual Studio 2013 ENU   06177-004-0444002-02032
Microsoft Office Developer Tools for Visual Studio 2013 ENU

Team Explorer for Visual Studio 2013   06177-004-0444002-02032
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02032
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02032
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02032
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02032
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02032
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02032
Windows Phone SDK 8.0 - ENU

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.0.11001.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.0
Provides common services for use by Azure Mobile Services and Windows Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Web Developer Tools 2013   2.0.40926.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

NuGet Package Manager   2.7.40911.287
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.30919.1
Microsoft SQL Server Data Tools

Windows Azure Mobile Services Tools   1.0
Windows Azure Mobile Services Tools

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.6.245.0 (49abddaaec0a8be4cb890b8cddefed81727bbe6c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.16.0.17 (2a7b68212b17c903160fbd8e0106babb299d1be3)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.0.52.0 (b38baf1c655f9fe816fee25cbd7ac78225def3e9)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 5 Jonathan Pryor 2015-02-23 11:15:50 UTC
Please attach diagnostic build output and the generated project.

My gut feeling is that the @(ProjectReference)s are somehow screwed up, and the PCL library isn't being properly referenced by the App project, which is why the assembly can't be found.
Comment 7 Jonathan Pryor 2015-02-23 13:40:04 UTC
The Build output from Comment #6 does not contain the warning from Comment #0 or Comment #4. It also doesn't appear to happen from a command-line `msbuild` invocation (please verify?).

Furthermore, I'm not able to repro this on OS X with Xamarin Studio; instead, when I create a "Blank App (Xamarin.Forms Portable)" application, I instead get the warning:

> Could not install package 'Xamarin.Forms 1.3.1.6296'.
> You are trying to install this package into a project that targets 'portable-Profile78',
> but the package does not contain any assembly references or content files that
> are compatible with that framework. For more information, contact the package author.

I'm inclined to believe that this is specific to the Visual Studio Add-in; perhaps VS is trying to build the main Application project before it's built the library projects?
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2015-02-23 13:57:04 UTC
Just a quick note: this precise bug report is aimed at a _warning_ that appears in Visual Studio before any attempt to build the project.

There were some scattered reports from customers about a build _error_ (like bug 27297), but I haven't seen that myself, _except_:

a. If I explicitly disable "Build" for the PCL project under "Build -> Configuration Manager" (roughly related to bug 25811, but I think Android uses the "Any CPU" for the "Active solution platform" by default, which doesn't have the same problem as iOS).

OR

b. If the PCL project fails to compile to due another build error. In that case, the build process continues on trying to build the Android project, but fails because the PCL `.dll` never got built.
Comment 9 Jonathan Pryor 2015-03-02 15:31:18 UTC
*** Bug 27297 has been marked as a duplicate of this bug. ***
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2015-09-16 19:58:21 UTC
*** Bug 33662 has been marked as a duplicate of this bug. ***
Comment 12 Jose Gallardo 2015-12-11 12:20:48 UTC
*** Bug 33748 has been marked as a duplicate of this bug. ***
Comment 15 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:47:36 UTC
*** Bug 39907 has been marked as a duplicate of this bug. ***
Comment 16 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 19:54:12 UTC
*** Bug 40647 has been marked as a duplicate of this bug. ***
Comment 17 Brendan Zagaeski (Xamarin Team, assistant) 2016-04-29 20:58:16 UTC
Since it has been a while since I last tested this bug, I have re-tested the behavior with the latest versions.




## Verification status: not yet fixed as of the latest Alpha version of XamarinVS 4.2.0

BAD: XamarinVS 4.2.0.21  (a532c82)
BAD: XamarinVS 4.1.0.462 (fb9e9f3)


### The warning message has _changed_ in 4.2.0, but it is still present

(Note: Bug 40782 discusses improving the _wording_ of this message to make it more consistent with other C# project types, particularly when it appears as a build _error_. But _this_ bug (Bug 23210) is about the fact that the _warning_ should not appear _at all_ when the user has just created a new project using a built in template. Apart from a few particular templates that _require_ users to add additional code before building them, there should be _no_ warnings or errors in the Error List after a user has created a new solution using one of the bundled project templates.)

> Warning		The "ResolveLibraryProjectImports" task failed unexpectedly.
> System.IO.FileNotFoundException: Could not load assembly 'MyFormsApp, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
> File name: 'MyFormsApp.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()
> MyFormsApp.Android	C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets	1057


Thanks!
Comment 33 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-11 22:37:48 UTC
*** Bug 44169 has been marked as a duplicate of this bug. ***
Comment 34 Brendan Zagaeski (Xamarin Team, assistant) 2016-12-27 04:36:00 UTC
*** Bug 45398 has been marked as a duplicate of this bug. ***
Comment 35 Brendan Zagaeski (Xamarin Team, assistant) 2016-12-27 08:09:29 UTC
I spent some time today investigating this issue in relation to Bug 30844.  I found that both issues could be generalized and simplified to use a test case that didn't involve Xamarin.Forms, and then I narrowed down the location of the regression based on the original finding from Comment 0.

I have filed the new generalized and simplified test case in a new bug report to provide a clean starting point for the final steps of the investigation.  I will accordingly mark this bug as a duplicate of the new bug.

*** This bug has been marked as a duplicate of bug 50914 ***