Bug 26767 - [Xamarin.Forms] Xamarin.Forms.Init() must be called prior to using it
Summary: [Xamarin.Forms] Xamarin.Forms.Init() must be called prior to using it
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: 1.3.5
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-05 04:54 UTC by Anubhav Ranjan
Modified: 2015-02-18 04:52 UTC (History)
6 users (show)

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


Attachments
Sample Project (302.64 KB, application/octet-stream)
2015-02-05 04:54 UTC, Anubhav Ranjan
Details
Zip Xamarin Logs (24.63 KB, application/octet-stream)
2015-02-05 06:07 UTC, Udham Singh
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 Anubhav Ranjan 2015-02-05 04:54:50 UTC
Created attachment 9655 [details]
Sample Project

One of our customers is facing issue when making use of Xamarin.Forms with Android.
Even though, the Forms.Init() is called, the application throws this exception

System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it.

#Code Snippet

protected override void OnCreate(Bundle bundle)
{
	base.OnCreate(bundle);
	global::Xamarin.Forms.Forms.Init(this, bundle);
	LoadApplication(new App()); //  Exception happens here
}
Comment 2 Udham Singh 2015-02-05 06:07:56 UTC
Created attachment 9658 [details]
Zip Xamarin Logs

I have checked this issue with the help of sample app given in bug description able to reproduce this. To reproduce this issue I have followed the steps below :

1. Open the Sample Project in VS 2013.
2. Set android project as start-up project
3. Run the project and got the issue.

Screencast : http://www.screencast.com/t/7LUrKI0kt4

Application Output : https://gist.github.com/Udham1/626aadee14dad059035a

Environment Info : 

Xamarin.Forms.1.3.3.6321-pre2

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin   3.9.293.0 (080a254)
Comment 3 Jason Smith [MSFT] 2015-02-10 02:29:25 UTC
Don't call Forms.Init in your splashscreen, you're not using it there, that said we will resolve this to work either way.
Comment 4 Jason Smith [MSFT] 2015-02-12 16:57:33 UTC
Should be fixed in 1.3.5-pre1
Comment 5 Parmendra Kumar 2015-02-18 04:52:53 UTC
I have checked this issue with Xamarin.Forms.1.3.5.6333-pre1 and now its working fine at my end.

Environment info:
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Xamarin   3.9.293.0 
Xamarin.Android   4.20.0.34
Xamarin.iOS   8.6.1.0 

Hence closing this issue.