Bug 28354 - CustomRendere throws "SetElement did not create the correct number of children"
Summary: CustomRendere throws "SetElement did not create the correct number of children"
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.1
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Jason Smith [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-03-24 03:44 UTC by Prashant Cholachagudda
Modified: 2016-04-08 19:18 UTC (History)
6 users (show)

Tags: android customrenderer ac
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:
Status:
RESOLVED FIXED

Description Prashant Cholachagudda 2015-03-24 03:44:03 UTC
The sample from https://github.com/slewis74/SearchWithTabsApp throws the "System.InvalidOperationException: SetElement did not create the correct number of children" exception.

We do not get the exception when we change TabbedView to be a ContentView in the code, but the controls/children elements never get rendered on any platform.

# Stacktrace

System.InvalidOperationException: SetElement did not create the correct number of children
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement,Xamarin.Forms.VisualElement) <IL 0x00173, 0x006b7>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () <IL 0x0000d, 0x00057>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<SearchWithTabsApp.Pages.TabbedView>.SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager) <0x0005b>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<SearchWithTabsApp.Pages.TabbedView>.SetElement (SearchWithTabsApp.Pages.TabbedView) <0x005e7>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<SearchWithTabsApp.Pages.TabbedView>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement) <0x0012f>
  at at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement) <IL 0x00022, 0x000ca>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement,Xamarin.Forms.Platform.Android.IVisualElementRenderer,Xamarin.Forms.Platform.Android.RendererPool,bool) <IL 0x00011, 0x0007f>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement,Xamarin.Forms.VisualElement) <IL 0x00116, 0x0054b>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () <IL 0x0000d, 0x00057>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.View>.SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager) <0x0005b>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.View>.SetElement (Xamarin.Forms.View) <0x005e7>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.View>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement) <0x0012f>
  at at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement) <IL 0x00022, 0x000ca>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement,Xamarin.Forms.Platform.Android.IVisualElementRenderer,Xamarin.Forms.Platform.Android.RendererPool,bool) <IL 0x00011, 0x0007f>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement,Xamarin.Forms.VisualElement) <IL 0x00116, 0x0054b>
  at at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () <IL 0x0000d, 0x00057>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.Page>.SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager) <0x0005b>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.Page>.SetElement (Xamarin.Forms.Page) <0x005e7>
  at at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.Page>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement) <0x0012f>
  at at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement) <IL 0x00022, 0x000ca>
  at at Xamarin.Forms.Platform.Android.Platform.AddChild (Xamarin.Forms.VisualElement,bool) <IL 0x00016, 0x00083>
  at at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page) <IL 0x00093, 0x00323>
  at at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page) <IL 0x000cf, 0x003d7>
  at at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () <IL 0x0000c, 0x0004b>
  at at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application) <IL 0x00034, 0x00163>
  at SearchWithTabsApp.Droid.MainActivity.OnCreate (Android.OS.Bundle) [0x00015] in /Users/prashantvc/Desktop items/Xamarin/136093/SearchWithTabsApp/SearchWithTabsApp.Droid/MainActivity.cs:20
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380
  at at (wrapper dynamic-method) object.c9f5aab4-c885-4788-a6dd-cca4fa32f58b (intptr,intptr,intptr) <IL 0x00017, 0x0001f>
Comment 1 Udham Singh 2015-03-24 06:39:51 UTC
I have checked this issue with the help of sample app given in bug description and able to reproduce this issue. Please refer the screencast : http://www.screencast.com/t/GWBzwaHq5ba

I am getting this issue with both android device and emulator.

Application Output : https://gist.github.com/Udham1/487e111182e21f1aab8e
Exception Log : https://gist.github.com/Udham1/dca661eb3a4665f47d7a
Build  Output : https://gist.github.com/Udham1/89f79f14a0200c6790d2
Ide Log : https://gist.github.com/Udham1/a8de050d1bc1fb79cc07

Environment Info : 

Xamarin.Forms : 1.3.1.6296

=== Xamarin Studio ===

Version 5.8.2 (build 5)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Xamarin.Android ===

Version: 4.20.1.0 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.2.2 (Business Edition)
Hash: f5d0c5e
Branch: 
Build date: 2015-03-20 06:51:49-0400

=== Xamarin.Mac ===

Version: 2.0.0.141 (Business Edition)

=== Build Information ===

Release ID: 508020005
Git revision: 541c06a4f6c95383333375d56fd6c23ce48cb916
Build date: 2015-03-20 09:23:08-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

=== Operating System ===

Mac OS X 10.9.5
Darwin Xamarin76s-Mac-mini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Chris King 2015-05-27 19:10:25 UTC
Thank you for taking the time to submit this report. We will work to resolve the issue you are encountering while creating your customer renderer. That said, is there an enhancement we can make to Forms so that you won't need to create a custom renderer? If so, please let us know as enhancing the platform in a way that prevents the need to create custom renderers will allow us to provide you a more stable platform.

Warm regards,
Xamarin Forms Team
Comment 3 Jason Smith [MSFT] 2016-04-08 19:18:41 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team