Bug 604 - MonoTouch build for device fails with its own NullReferenceException
Summary: MonoTouch build for device fails with its own NullReferenceException
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
: 610 ()
Depends on:
Reported: 2011-09-02 07:08 UTC by rumination.xamarin
Modified: 2011-09-07 14:43 UTC (History)
4 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 rumination.xamarin 2011-09-02 07:08:09 UTC
I just updated to MT 4.0.7. Now when I try to build for device I get:

Error 1: mtouch failed with the following message:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at MonoTouch.Registrar.TypeSystemDescriptor.MethodMatch (Mono.Cecil.MethodDefinition candidate, Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.PropertyMatch (Mono.Cecil.PropertyDefinition candidate, Mono.Cecil.PropertyDefinition property) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.TryMatchProperty (Mono.Cecil.TypeDefinition type, Mono.Cecil.PropertyDefinition property) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.GetBasePropertyInTypeHierarchy (Mono.Cecil.PropertyDefinition property) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor+<CollectCandidateProperties>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.ProcessMethods (Mono.Cecil.TypeDefinition type, MonoTouch.Registrar.Class class) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.ProcessType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.Process (IEnumerable`1 assemblies) [0x00000] in <filename unknown>:0 
  at MonoTouch.Registrar.TypeSystemDescriptor.Describe (IEnumerable`1 assemblies) [0x00000] in <filename unknown>:0 
  at Registrar.Generate (System.Collections.Generic.List`1 list, MonoTouch.Tuner.MonoTouchResolver resolver) [0x00000] in <filename unknown>:0 
  at MTouch.RunRegistrar (System.Collections.Generic.List`1 assemblies, System.String assemblies_path, System.String output_dir, System.String& output_file) [0x00000] in <filename unknown>:0 
  at MTouch.CompileToNative (System.String user_gcc_flags, System.Collections.Generic.List`1 assemblies) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0 

Building for simulator still works.
Comment 1 Sebastien Pouliot 2011-09-02 08:54:55 UTC
Looks related to the new [Outlet] and [Action] support that requires the processing of properties.
Comment 2 Sebastien Pouliot 2011-09-02 09:09:32 UTC
I have a fix but no test case to ensure it covers everything afterward. Do you have a small sample that demonstrate this ?

Also can you try to build using "--noregistrar" (in mtouch extra arguments) to see if this can be a (temporary) workaround. That will also tell me if there are issues after the registrar (since my fix is there).
Comment 3 Sebastien Pouliot 2011-09-02 16:26:25 UTC
*** Bug 610 has been marked as a duplicate of this bug. ***
Comment 4 rumination.xamarin 2011-09-02 19:33:45 UTC
Sorry, I do not have a small test case.

"--noregistrar" does eliminate the problem in my solution.

Please advise on when I can expect to see this fix in the "Stable" update path. The other bugs I've reported haven't yet been addressed in "Stable", and the release notes for each such version are minimal to say the least, so I'm at loss to understand how and when critical fixes will reach me.
Comment 5 Sebastien Pouliot 2011-09-02 20:12:06 UTC
Thank you for confirming the workaround, this will likely prove useful to others as well. 

A fix* is already committed for the next releases, including stable (not all bugs can be directly fixed in the stable branch). I can't say 'when', it depends on many other things, but you're welcome to ask by emailing contact@xamarin.com

* unconfirmed until I have a test case
Comment 6 rumination.xamarin 2011-09-03 22:40:17 UTC
Just to clarify, the "--noregistrar" flag suffices to successfully complete a device build. But in actuality this is not a reasonable workaround. My app thusly built will not launch on an iPhone 3G in time to beat the iOS watchdog timer, so it's killed. I didn't even try other devices after that result.

I understand you can't commit to future release dates. I'll take that up with customer support if it doesn't happen "soon". In the meantime, and for the benefit of others stuck in the same position, will it work to install a previous version of MonoTouch over the current version? If so, can you please post a link to the last Stable version before 4.0.7?
Comment 7 Sebastien Pouliot 2011-09-07 14:43:45 UTC
The fix will be in 4.0.8 (if released), 4.2 (soon to be released) and future alpha/beta releases.

> If so, can you please post a link to the last Stable version before 4.0.7?

go to activation.monotouch.net
you'll need your activation/upgrade code