Bug 24196 - TargetInvocationException when using OnPlatform in Xaml only when running on an iOS Device
Summary: TargetInvocationException when using OnPlatform in Xaml only when running on ...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jason Smith [MSFT]
Depends on:
Reported: 2014-10-31 13:18 UTC by John Miller [MSFT]
Modified: 2015-06-26 19:56 UTC (History)
6 users (show)

Tags: ios crash xaml
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 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:

Description John Miller [MSFT] 2014-10-31 13:18:49 UTC

   Using OnPlatform for color of a TabbedPage in xaml causes an exception only when running on a device. 

**Steps to Reproduce:**

   1. Create a TabbedPage with Xaml. 
   2. Add xaml for the background color.

    <OnPlatform x:TypeArguments="Color" iOS="#FFFFF6" Android="#FFFFF6" WinPhone="Default"/>

**Actual Results:**

  >Unhandled managed exception: Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
  >at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543 
  >at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x000af] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:329 
  >at System.Activator.CreateInstance (System.Type type) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:222 
  >at Xamarin.Forms.Xaml.ElementNode.Create (Boolean dontUseLazy) [0x00000] in <filename unknown>:0 

**Expected Results:**

  No exception.

**Build Date & Platform:**

   XF 1.2.3
   VS 2013 Update 3

**Additional Information:**

   It works on a simulator.
Comment 1 Sadik Ali 2014-11-03 07:20:17 UTC
I have checked this issue but I am not able to reproduce this issue.

Steps I followed:

1. Create a Mobile App ( Xamarin.Forms Portable)
2. Create a Tapped page.
3. Write the following code 

    <OnPlatform x:TypeArguments="Color" iOS="#FFFFF6" Android="#FFFFF6"

When I deploy application on device, I am not getting any error/exception. I am able to deploy application successfully on both devices android and iOS.
Could you please provide sample application and build information ? So that we can reproduce this issue at our end

Environment Info:


Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin (8ca7d11db8a6f874c6cd2de6d9ca0f511867ce91)
Xamarin.Android (5474129af31e9d3a86cb7482c7c5c7a30ad315f1)
Xamarin.iOS (209abebbd8f1a292d042420edb45fa5fbd3f017b)
Comment 4 Udham Singh 2014-11-05 11:29:35 UTC
I have checked this issue and getting the same exception mentioned in bug description. To reproduce this issue I have used the sample app attached in comment 2 and got the same exception when run this on iOS device(iPhone 5S - iOS 7.1).

Screencast : http://www.screencast.com/t/xFV2Aellqe

Application Output : https://gist.github.com/Udham1/c6bcfdcdde3bd53a0dfc

Environment Info :

Windows 8
VS 2013
Xamarin.iOS Build Host
Comment 5 Erik Renaud 2014-11-05 14:09:39 UTC
Now that we have a confirmed repro... when can we expect a fix ?
Comment 6 Erik Renaud 2015-01-03 20:16:41 UTC
Any news ? it`s been over a month !
Comment 7 Seth Rosetter 2015-06-01 18:53:28 UTC
The attached sample is no longer available and I am unable to reproduce given the description. Is this still a problem for you?
Comment 8 Erik Renaud 2015-06-01 21:26:09 UTC
I can't say, I completely changed architecture to bypass the bugs.
Comment 9 Jason Smith [MSFT] 2015-06-26 19:56:55 UTC
We can no longer repro this. The original issue is almost certainly a case of the linker being unfriendly.