Bug 5146 - Linking issue when 2 applications share a project reference
Summary: Linking issue when 2 applications share a project reference
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 5611 ()
Depends on:
Blocks:
 
Reported: 2012-05-17 13:42 UTC by Scott Dancer
Modified: 2012-09-21 06:25 UTC (History)
7 users (show)

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


Attachments
Solution with Problem (1.61 MB, application/x-zip-compressed)
2012-05-17 14:23 UTC, Scott Dancer
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 FIXED

Description Scott Dancer 2012-05-17 13:42:40 UTC
The newest release introduced an issue where it's not pulling in the assembly in a particular scenario.  I've reproduced the issue in the attached project.  You should see this exception for the LinkErrorProject when you build.


Error	4	Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Lidgren.Network.Android, Version=2011.3.12.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Lidgren.Network.Android.dll'
   at Monodroid.Tuner.MonoDroidResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute()	LinkErrorProject
Comment 1 Scott Dancer 2012-05-17 14:23:18 UTC
Created attachment 1909 [details]
Solution with Problem
Comment 2 Jonathan Pryor 2012-05-17 16:58:50 UTC
At present your Application project must reference all assemblies that are to be included into your .apk. I suspect that your App project isn't referencing the Lidgren.Network.Android.dll and/or project.

See also the discussion in bug #5151.
Comment 3 Scott Dancer 2012-05-17 17:19:30 UTC
All projects in the solution are referencing (project reference) the project that it can't find.  So, that can not be the issue.
Comment 4 Jonathan Pobst 2012-05-17 18:07:32 UTC
The quick workaround for this is that MonoGame.Framework.Android.csproj is set to be an Android Application instead of an Android Class Library.

If you remove <AndroidApplication>true</AndroidApplication> from MonoGame.Framework.Android.csproj, it should fix the issue.

I'll have to dig deeper to figure out why this causes a problem and how to fix it.
Comment 5 Marcos Cobeña Morián 2012-05-31 06:33:31 UTC
Hi,

M4A 4.2.2 fixes bug #5151, which looks similar to this one, but I keep getting the same error:

Error	210	Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Lidgren.Network.Android, Version=2011.3.12.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Lidgren.Network.Android.dll'
   at Monodroid.Tuner.MonoDroidResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute()	ZombeeeFloatAndroid


Do you have any new on this?

Thanks,

Marcos
Comment 6 Jonathan Pobst 2012-05-31 10:39:40 UTC
Did you try what was listed in Comment #4?  It fixes the issue for me and the original reporter.
Comment 7 Marcos Cobeña Morián 2012-06-01 02:39:46 UTC
Yes, I tried it, but it didn't work.

Our scenario at Cell SDK is a little more complex than a XNA game. We have multiple projects and MonoGame/Lidgren are referenced on multiple places.

We've been able to run Cell SDK on M4A 4.2.x adding references everywhere but, as I read you'll come back to implicit references, we're waiting for a fix on this from Xamarin.
Comment 8 Jonathan Pobst 2012-06-12 14:58:14 UTC
*** Bug 5611 has been marked as a duplicate of this bug. ***
Comment 9 Atsushi Eno 2012-09-18 11:00:17 UTC
With the latest release (4.2.5), beta (4.2.6) or master, I only get:

error CS1681: The global extern alias cannot be redefined

So the cause of the failure has changed.
Comment 10 Atsushi Eno 2012-09-21 06:25:03 UTC
After I removed alias in the corresponding csproj, I got another error regarding sharing violation on *.stamp. Now I fixed it and it built on our internal master. So I take it as fixed.