Bug 2498 - Can't call Start on Threads without crash
Summary: Can't call Start on Threads without crash
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-12-14 10:56 UTC by Clay Fowler
Modified: 2011-12-14 11:19 UTC (History)
2 users (show)

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 Clay Fowler 2011-12-14 10:56:42 UTC
On the beta channel (version info below), any attempt to call Start() on instances of Thread die with a NullReferenceException at this point in Thread.cs:

		IDisposable GetNSAutoreleasePool ()
			if (nsautoreleasepool_ctor == null) {
				Type t = Type.GetType ("MonoTouch.Foundation.NSAutoreleasePool, monotouch, Version=, Culture=neutral, PublicKeyToken=null");
				nsautoreleasepool_ctor = t.GetConstructor (Type.EmptyTypes);
			return (IDisposable) nsautoreleasepool_ctor.Invoke (null);

The variable t is null, so calling t.GetConstructor blows up. Apparently there is no "MonoTouch.Foundation.NSAutoreleasePool, monotouch, Version=, Culture=neutral, PublicKeyToken=null" to be found.

So, we cannot start any threads with this version.

Version Info:
MonoDevelop 2.9.1
	Mono 2.10.7 (tarball Mon Dec  5 20:41:19 EST 2011)
	GTK 2.24.8
	GTK# (
Apple Developer Tools:
	 Xcode 4.2 (828)
	 Build 4D199
Monotouch: 5.1.1
Comment 1 Sebastien Pouliot 2011-12-14 11:19:31 UTC
This is already fixed and will be part of MonoTouch 5.1.2 beta.

There are two workarounds possible. You can either:

1. disable linking in your application (but you'll get larger apps and longer build times); or

2. Add some code in your application that will call NSAutoreleasePool - that way the linker won't elimitate it and the reflection call will work.