Bug 22342 - TinyIoc doesn't work in Android when linker is set to link SDK only
Summary: TinyIoc doesn't work in Android when linker is set to link SDK only
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.14.0
Hardware: PC Windows
: Normal normal
Target Milestone: 5.1
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2014-08-25 12:10 UTC by Kent Green [MSFT]
Modified: 2015-04-29 16:44 UTC (History)
7 users (show)

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


Attachments
Logfiles from the error (4.79 KB, application/x-zip-compressed)
2014-08-25 12:10 UTC, Kent Green [MSFT]
Details
Sample project which recreates the issue (32.13 KB, application/zip)
2014-08-25 18:39 UTC, Isaac Devine
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:
VERIFIED FIXED

Description Kent Green [MSFT] 2014-08-25 12:10:35 UTC
Created attachment 7789 [details]
Logfiles from the error

---Overview---
From priority case: https://xamarin.desk.com/agent/case/85198
Customer reports that this bug appears identical to this Resolved Fixed bug for iOS: https://bugzilla.xamarin.com/show_bug.cgi?id=14863

Specifically, TinyIoc isn't working when the linker is set to "Link SDK assemblies only." 

---Workaround---
The customer noted they were able to workaround the issue by excluding System.Core from linking.

---Log file notes---
There are some "AD7DebugException" events in the IDE log file.
In the Android logcat file, tons of exceptions and several stack traces occur throughout the file. Here's the first exception that occurs in it:

>I/MonoDroid(15849): UNHANDLED EXCEPTION: Cirrious.CrossCore.Exceptions.MvxException: Failed to create instance of Trimble.MCS.PuckApp.UI.Droid.Setup ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: Trimble.MCS.PuckApp.Core.Common.SettingsManager ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: Trimble.MCS.PuckApp.Core.Common.SettingsManager ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: Trimble.MCS.PuckApp.Core.Common.XmlSettingsStore ---> System.NullReferenceException: Object reference not set to an instance of an object
>I/MonoDroid(15849):   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
08-22 12:09:47.597 I/MonoDroid(15849):   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
>I/MonoDroid(15849):   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.Linq.Expressions.ParameterExpression[] parameters) [0x00000] in <filename unknown>:0 
>I/MonoDroid(15849):   at TinyIoC.TinyIoCContainer+MultiInstanceFactory.GetObject (System.Type requestedType, TinyIoC.TinyIoCContainer container, TinyIoC.NamedParameterOverl08-22 12:09:47.597 I/MonoDroid(15849):   at TinyIoC.TinyIoCContainer.CreateObjectConstructionDelegateWithCache (System.Reflection.ConstructorInfo constructor) [0x00000] in <filename unknown>:0 

---Build Information---
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.50938
 
Installed Version: Professional
 
LightSwitch for Visual Studio 2013   06177-004-0446025-02398
Microsoft LightSwitch for Visual Studio 2013
 
Team Explorer for Visual Studio 2013   06177-004-0446025-02398
Microsoft Team Explorer for Visual Studio 2013
 
Visual Basic 2013   06177-004-0446025-02398
Microsoft Visual Basic 2013
 
Visual C# 2013   06177-004-0446025-02398
Microsoft Visual C# 2013
 
Visual C++ 2013   06177-004-0446025-02398
Microsoft Visual C++ 2013
 
Visual F# 2013   06177-004-0446025-02398
Microsoft Visual F# 2013
 
Visual Studio 2013 Code Analysis Spell Checker   06177-004-0446025-02398
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-0446025-02398
Windows Phone SDK 8.0 - ENU
 
AnkhSVN - Subversion Support for Visual Studio   2.5.12471.17
AnkhSVN - Subversion Support for Visual Studio 2.5.12471.17 
 * Ankh.Package 2.5.12471.17
 * Subversion 1.8.9 via SharpSvn 1.8009.3299.43
 
SharpSvn is linked to: Apr 1.5.1, Apr-util 1.5.3, Cyrus Sasl 2.1.25, eXpat 2.0.1, OpenSSL 1.0.1g 7 Apr 2014, serf 1.3.5, SQLite 3.7.17, Subversion 1.8.9-SharpSvn-1.8.9, ZLib 1.2.8
SharpSvn is optionally linked to: Berkeley DB 4.4.20, SharpPlink 1.8009.3299.43
 
Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio
 
ASP.NET and Web Tools   12.3.50717.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 Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure
 
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.2.20703.0
For additional information, visit http://www.asp.net/
 
Common Azure Tools   1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
 
Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 
 
Microsoft Azure Mobile Services Tools   1.2
Microsoft Azure Mobile Services Tools
 
NuGet Package Manager   2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
 
Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU
 
PowerShell Tools   1.2
Provides file classification services using PowerShell
 
PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
 
SAPReferenceManager   1.0
Manages References to Shared Projects
 
SQL Server Data Tools   12.0.30919.1
Microsoft SQL Server Data Tools
 
VsVim   1.7.0.0
VsVim is a Vim emulator for Visual Studio
 
Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.
 
Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.
 
Xamarin   3.3.47.0 (0b2a123923812a88ed3091909478dbe9e0111f00)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 1 Isaac Devine 2014-08-25 18:39:18 UTC
Created attachment 7792 [details]
Sample project which recreates the issue

Looking at the Android Debug Log will show the exceptions.
Comment 2 Tajinder Singh 2014-08-26 09:48:26 UTC
I have checked this Issue with attached project and I am not seeing any exception in android log:

Adb logcat: https://gist.github.com/Parmendrak/a79d64877565ce516d07
Android Device logging: https://gist.github.com/Parmendrak/4e1281372ebe5269ff1d

I have just debug attached solution after cshanging Linking to SDk Assemblies Only.

Please let me know if I have missed anything here to reproduce this.

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

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

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

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

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

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

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

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02685
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-02685
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.3.50717.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 Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

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.2.20703.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools   1.2
Microsoft Azure Mobile Services Tools

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

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.2
Provides file classification services using PowerShell

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 Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

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

Xamarin   3.3.47.0 (0b2a123923812a88ed3091909478dbe9e0111f00)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 3 Kent Green [MSFT] 2014-08-26 11:08:04 UTC
I asked the reporting customer for the following info for reproducing the issue:

1) Which Android Version/API level(s) are you targeting when you see the error?
- Compile using Android: Level 19 ( version 4.4)
- Minimum Android: Level 16 ( Target 4.1 )
- Target Android: Level 16 ( Version 4.1)


2) Do you encounter the issue when deploying in debug mode, release mode, or both?
- Release mode (or debug if link sdk assemblies is enabled)


3) Do you encounter it when testing on an emulator, a physical device, or both?
- Physical Device (Nexus 5) and Emulator (KitKat), though I don’t get anything in the device log in the emulator.
Comment 4 John Miller [MSFT] 2014-08-26 13:38:16 UTC
I tested on my Nexus 5 with Link SDK assemblies and I was able to reproduce a crash on launch. 

>Unhandled Exception:
>[mono] TinyIoC.TinyIoCResolutionException: Unable to resolve type: LinkerBugExample.Example.ConcreteClass ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: LinkerBugExample.Example.ConcreteClass ---> System.NullReferenceException: Object reference not set to an instance of an object
>[mono]   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
>[mono]   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
>[mono]   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.Linq.Expressions.ParameterExpression[] parameters) [0x00000] in <filename unknown>:0 
>[mono]   at TinyIoC.TinyIoCContainer
>[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: TinyIoC.TinyIoCResolutionException: Unable to resolve type: LinkerBugExample.Example.ConcreteClass ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: LinkerBugExample.Example.ConcreteClass ---> System.NullReferenceException: Object reference not set to an instance of an object
>[mono-rt]   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
>[mono-rt]   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
>[mono-rt]   at System.Linq.Expressions.Expression.Lambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.Linq.Expressions.ParameterExpression[] parameters) [0x00000] in <filename unknown>:0 
>[mono-rt]   at TinyIoC.Tin
Comment 6 Radek Doulik 2014-11-24 07:57:10 UTC
This is fixed in master by commit a66a312489e87f736eb05bf4fa4c3b021c937b0b