Bug 19500

Summary: Upgrade to 7.2.1 Causes "Non-Static method requires a target"
Product: iOS Reporter: Dillon Buchananq <thedillonb>
Component: GeneralAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: danisha, edgeric, ghigh, jarroda, mono-bugs+monotouch, rolf
Priority: Normal    
Version: 7.2.1   
Target Milestone: Untriaged   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Dillon Buchananq 2014-05-02 18:27:54 UTC
The following issue can be reproduced with the following: https://github.com/thedillonb/XamarinTargetNull

Code that was originally working in 7.2.0 is now broken in 7.2.1 due to a "Non-Static method requires a target" issue that arises with nullable objects.

The code example attempts to JSON serialize a nullable object using a previously working SimpleJSON library (single .cs file - also attached). The SimpleJSON library does extensive Expression handling, but for what ever reason, leaves me with a "Non-static method requires a target" exception.
Comment 1 Dillon Buchananq 2014-05-02 18:29:28 UTC
Before being quick to blame the SimpleJson library it should be noted that it works on all other platforms.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-05-05 10:42:32 UTC
Marek, it looks like this is related to the new interpreter support:

Unhandled managed exception: Non-static method requires a target. (System.Reflection.TargetException)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006b] in /work/monotouch/master/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:243 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /work/monotouch/master/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:114 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.InvokeWorker (System.Object[] args) [0x00030] in /work/monotouch/7.2.1/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs:268 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.Invoke (System.Object[] args) [0x00000] in /work/monotouch/7.2.1/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs:239 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0003b] in /work/monotouch/7.2.1/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs:289 
  at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0001b] in /work/monotouch/7.2.1/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs:126
Comment 3 Marek Safar 2014-05-05 13:44:48 UTC
Fixed in Mono master
Comment 4 Dillon Buchananq 2014-05-05 14:02:34 UTC
Any idea when this will hit a stable Xamarin.iOS release?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2014-05-06 04:46:33 UTC
@Dillon, at the moment no, but it usually takes between a month or two.
Comment 6 Gerry 2014-06-19 01:21:35 UTC
I can confirm this error also occurs with Json.Net in the same scenario.  It is still broken in 7.2.3.39.

I am surprised that something as important as this bug fix would take a month or two to make it into the stable release.  You're requiring everyone to jump onto alpha/beta?

I can also confirm that it is not fixed in the beta channel 7.2.4.4 but is fixed in the alpha channel 7.2.6.3.

Thanks,
Gerry