I have a Xamarin.IOS application and use MvvmCross and the ResxPlugin for translations. That workes without issues in debug. But since I updated from I guess 5.3.x to 5.6.3 the app crashes in release mode with the linker set to "Link Framework SDKs only" when I try to execute the following line:
bindingSet.Bind(textViewWelcomeMessage)
.For(txt => txt.Text)
.To(vm => vm.TextSource)
.WithConversion(new MvxLanguageConverter(), "WelcomeMessage");
This works without issues:
bindingSet.Bind(textFieldAgreementText)
.For(lbl => lbl.AttributedText)
.To(vm => vm.GeneralAgreementText)
.WithConversion("StringToHtml");
So I assume the problem lies somewhere in the MvxLanguageConverter in combination with textFields.
In my "LinkerPleaseInlude" file I have this added:
public void Include(UITextView textView)
{
textView.Text = textView.Text + "";
textView.AttributedText = new NSAttributedString();
textView.Changed += (sender, args) => { textView.Text = ""; };
}
The error message in the output is:
2018-01-24 09:37:39.415 ConnectContacts.Ios[27680:1063685] System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Binding.iOS.Target.MvxUITextViewTextTargetBinding.SubscribeToEvents () [0x00053] in <614c9ef828c14ba687a40ec2656f480f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <866b1e46764b48aab0d408952a6f006f>:0
at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () [0x0003a] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindings, System.Object clearKey) [0x0001d] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindingDescriptions, System.Object clearKey) [0x00018] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x0000b] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[TTarget].Apply () [0x0001f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[TOwningTarget,TSource].Apply () [0x00016] in <866b1e46764b48aab0d408952a6f006f>:0
at ConnectContacts.Ios.Views.Wizard.WelcomeView.ViewDidLoad () [0x001ae] in <b2a318752d5d4fbeb6d32a83c8b6f752>:0
--- End of stack trace from previous location where exception was thrown ---
Do I have to make something different with the new version?
You need to add the following to your LinkerPleaseInlude for UITextView
textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";
See this GitHub issue
Related
I am building a cross platform app using Xamarin and MvvmCross. So far I have worked on the Android version and everything was great. I just started working on the iOS app, create a blank project and tried to add a reference to the MvvmCross binaries. I managed to add references to Cirrious.CrossCore.Touch.dll, Cirrious.MvvmCross.Binding.Touch.dll and Cirrious.MvvmCross.Touch.dll but could not add references to Cirrious.CrossCore.dll, Cirrious.MvvmCross.Binding.dll and Cirrious.MvvmCross.dll. Everytime I try I get the following exception
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00045] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System/AppDomain.cs:803
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string,System.Security.Policy.Evidence,bool)
at System.Reflection.Assembly.ReflectionOnlyLoad (System.String assemblyString) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Reflection/Assembly.cs:599
at IKVM.Reflection.Universe.DefaultResolver (System.String refname, Boolean throwOnError) [0x0001f] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Universe.cs:814
at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, Boolean throwOnError) [0x0002b] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Universe.cs:768
at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRefImpl (IKVM.Reflection.Metadata.Record& rec) [0x000b4] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Reader/ModuleReader.cs:523
at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRef (Int32 index) [0x0004b] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Reader/ModuleReader.cs:506
at IKVM.Reflection.Reader.ModuleReader.ResolveType (Int32 metadataToken, IGenericContext context) [0x000e9] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Reader/ModuleReader.cs:389
at IKVM.Reflection.Module.ResolveType (Int32 metadataToken, IKVM.Reflection.Type[] genericTypeArguments, IKVM.Reflection.Type[] genericMethodArguments) [0x00025] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Module.cs:433
at IKVM.Reflection.Module.ResolveType (Int32 metadataToken) [0x00005] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Module.cs:400
at IKVM.Reflection.Reader.ModuleReader.GetMemberRef (Int32 index, IKVM.Reflection.Type[] genericTypeArguments, IKVM.Reflection.Type[] genericMethodArguments) [0x000fd] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Reader/ModuleReader.cs:813
at IKVM.Reflection.Reader.ModuleReader.ResolveMethod (Int32 metadataToken, IKVM.Reflection.Type[] genericTypeArguments, IKVM.Reflection.Type[] genericMethodArguments) [0x00066] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Reader/ModuleReader.cs:717
at IKVM.Reflection.Module.ResolveMethod (Int32 metadataToken) [0x00005] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/Module.cs:441
at IKVM.Reflection.CustomAttributeData.get_Constructor () [0x00013] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/CustomAttributeData.cs:571
at IKVM.Reflection.CustomAttributeData.get_AttributeType () [0x00002] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/external/ikvm/reflect/CustomAttributeData.cs:562
at MonoDevelop.IPhone.IPhoneProject.<IsAssemblyCallingNativeCode>m__15 (IKVM.Reflection.CustomAttributeData a) [0x00001] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Project/IPhoneProject.cs:343
at System.Linq.Enumerable.Any[CustomAttributeData] (IEnumerable`1 source, System.Func`2 predicate) [0x0001a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/System.Core/System.Linq/Enumerable.cs:146
at MonoDevelop.IPhone.IPhoneProject.IsAssemblyCallingNativeCode (System.String file) [0x0003d] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Project/IPhoneProject.cs:343
at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator34`1[System.String].MoveNext () [0x00044] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/System.Core/System.Linq/Enumerable.cs:3127
at MonoDevelop.IPhone.IPhoneProject.ValidateReference (Xamarin.Components.Ide.Activation.XamarinEntitlements entitlements, MonoDevelop.Projects.ProjectReference reference) [0x00083] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Project/IPhoneProject.cs:309
at Xamarin.Ide.ActivationHelper.FindReferencesRequiringUpgrade (IXamarinProject project, Xamarin.Components.Ide.Activation.XamarinEntitlements entl, System.Collections.Generic.List`1 references, System.Collections.Generic.List`1& reasons, System.Collections.Generic.List`1& delayedReferences) [0x00029] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/md-addins/Xamarin.Ide/Xamarin.Ide/Xamarin.Ide.Accounts/ActivationHelper.cs:141
at Xamarin.Ide.ActivationHelper.ReferenceValidator (System.Object sender, MonoDevelop.Ide.EditReferencesEventArgs e) [0x00066] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/md-addins/Xamarin.Ide/Xamarin.Ide/Xamarin.Ide.Accounts/ActivationHelper.cs:90
at MonoDevelop.Ide.ProjectOperations.AddReferenceToProject (MonoDevelop.Projects.DotNetProject project) [0x0010b] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs:769
at MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectReferenceFolderNodeCommandHandler.AddReferenceToProject () [0x00023] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectReferenceFolderNodeBuilder.cs:210
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00069] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Reflection/MonoMethod.cs:238
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Reflection/MethodBase.cs:114
at MonoDevelop.Components.Commands.DefaultCommandHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00019] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:2094
at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00009] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CustomCommandTargetAttribute.cs:101
at MonoDevelop.Ide.Gui.Components.NodeCommandHandler+TransactedNodeHandlerAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x0002d] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs:296
at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.MonoDevelop.Components.Commands.ICommandTargetHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00004] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CustomCommandTargetAttribute.cs:58
at MonoDevelop.Components.Commands.CommandHandlerInfo.Run (System.Object cmdTarget, MonoDevelop.Components.Commands.Command cmd) [0x00021] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1963
at MonoDevelop.Components.Commands.CommandManager+<DispatchCommand>c__AnonStorey82.<>m__D2 () [0x0005f] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1054
at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x002b0] in /Users/builder/data/lanes/monodevelop-lion-license-sync/c5f82958/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1071
I have looked around but could not find anyone with the same issues. I am not using PCL it is a blank new iOS project.
There are two possible solutions:
Add the references from a NuGet package. You would need the MvvmCross Hot Tuna Starter Pack.
Use the Ninja Coder extensions https://visualstudiogallery.msdn.microsoft.com/618b51f0-6de8-4f85-95ce-a50c658c7767.
In my Xamarin app when I call this method
private void MakePayment (SKProduct product)
{
SKPayment payment = SKPayment.PaymentWithProduct (product);
SKPaymentQueue.DefaultQueue.AddPayment (payment);
}
I get this error:
Failed to marshal the Objective-C object 0x14607110 (type:
SKPaymentTransaction). Could not find an existing managed instance for
this object, nor was it possible to create a new managed instance
(because the type 'MonoTouch.StoreKit.SKPaymentTransaction[]' does not
have a constructor that takes one IntPtr argument).
I'm not sure if I have something configured wrong or there is an issue in my code or Xamarin.
Here's the code for the Observer
internal class CustomPaymentObserver : SKPaymentTransactionObserver
{
private InAppPurchase inAppPurchase;
public CustomPaymentObserver (InAppPurchase inAppPurchase)
{
this.inAppPurchase = inAppPurchase;
}
public override void UpdatedTransactions (SKPaymentQueue queue, SKPaymentTransaction[] transactions)
{
Console.WriteLine ("UpdatedTransactions");
foreach (SKPaymentTransaction transaction in transactions) {
switch (transaction.TransactionState) {
case SKPaymentTransactionState.Purchased:
inAppPurchase.CompleteTransaction (transaction);
break;
case SKPaymentTransactionState.Failed:
inAppPurchase.FailedTransaction (transaction);
break;
default:
break;
}
}
}
public override void PaymentQueueRestoreCompletedTransactionsFinished (SKPaymentQueue queue)
{
}
public override void RestoreCompletedTransactionsFailedWithError (SKPaymentQueue queue, NSError error)
{
}
}
Here is the full stack trace:
System.Exception: Failed to marshal the Objective-C object 0x17ecb680 (type: SKPaymentTransaction). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'MonoTouch.StoreKit.SKPaymentTransaction[]' does not have a constructor that takes one IntPtr argument).
at MonoTouch.ObjCRuntime.Runtime.MissingCtor (IntPtr ptr, IntPtr klass, System.Type type, MissingCtorResolution resolution) [0x00046] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pp-Runtime.cs:352
at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject[NSObject] (IntPtr ptr, System.Type type, MissingCtorResolution missingCtorResolution) [0x00000] in :0
at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr, System.Type target_type, MissingCtorResolution missingCtorResolution, System.Boolean& created) [0x00073] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pp-Runtime.cs:514
at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr, IntPtr type_ptr, System.Boolean& created) [0x0000c] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pp-Runtime.cs:686
at at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr,intptr,int&)
at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr (intptr,intptr,intptr)
at MonoTouch.StoreKit.SKPaymentQueue.AddPayment (MonoTouch.StoreKit.SKPayment payment) [0x00014] in /Developer/MonoTouch/Source/monotouch/src/StoreKit/.pp-SKPaymentQueue.g.cs:109
at IOS.Util.IAP.InAppPurchase.ReceivedResponse (MonoTouch.StoreKit.SKProductsRequest request, MonoTouch.StoreKit.SKProductsResponse response) [0x0001d] in /Users/aaron/Projects/budget-ease-xamarin/IOS/Util/IAP/InAppPurchase.cs:43
at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIApplication.cs:38
at IOS.Application.Main (System.String[] args) [0x00008] in /Users/aaron/Projects/budget-ease-xamarin/IOS/Main.cs:16
What's happened here is that the C# instance of your CustomPaymentObserver got garbage collected, while it's native ("Objective-C") counterpart lived on. When a notification was finally delivered, the native object tried to call into the now dead C# object and crashed your App.
To circumvent this, keep a reference to your CustomPaymentObserver e.g. in your AppDelegate to keep it alive.
I'm not sure this is documented somewhere for Xamarin.iOS (couldn't find something on a quick look), but I believe very similar for Xamarin.Droid (e.g. http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/)
I'm not really sure what was causing this. I thought it was perhaps something related to the linker. But I uninstalled Xamarin completely from my Mac (including all the MonoTouch stuff) and reinstalled everything and now it's working.
We are using data binding in our Xamarin.IOS project using MvvmCross(Hot Tuna version) as specified in the sample app “N-39-CrossLight-Touch”.
The sample app as well as our project works fine on simulator(IOS7) but on device(IOS7) it throws the below exception while binding.
System.ArgumentNullException: missing source event info in
MvxWeakEventSubscription Parameter name: sourceEventInfo at
Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription2[System.ComponentModel.INotifyPropertyChanged,System.ComponentModel.PropertyChangedEventArgs]..ctor
(INotifyPropertyChanged source, System.Reflection.EventInfo
sourceEventInfo, System.EventHandler1 targetEventHandler) [0x00000] in
:0 at
Cirrious.CrossCore.WeakSubscription.MvxNotifyPropertyChangedEventSubscription..ctor
(INotifyPropertyChanged source, System.EventHandler1
targetEventHandler) [0x00000] in :0 at
Cirrious.CrossCore.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe
(INotifyPropertyChanged source, System.EventHandler1 eventHandler)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxLeafPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxSimpleLeafPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxPropertySourceBindingFactoryExtension.CreateLeafBinding
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
propertyToken) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxPropertySourceBindingFactoryExtension.TryCreateBinding
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
currentToken, System.Collections.Generic.List1 remainingTokens,
IMvxSourceBinding& result) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.TryCreateBindingFromExtensions
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
propertyToken, System.Collections.Generic.List1 remainingTokens,
IMvxSourceBinding& result) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding
(System.Object source, IList1 tokens) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding
(System.Object source, System.String combinedPropertyName) [0x00000]
in :0 at
Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxPathSourceStep.OnDataContextChanged
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxSourceStep.set_DataContext
(System.Object value) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.CreateSourceBinding
(System.Object source) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding..ctor
(Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle
(Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder+<>c_DisplayClass1.b_0
(Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription
description) [0x00000] in :0 at
System.Linq.Enumerable+c__Iterator102[Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription,Cirrious.MvvmCross.Binding.Bindings.IMvxUpdateableBinding].MoveNext
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings
(IMvxBindingContextOwner view, IEnumerable1 bindings, System.Object
clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings
(IMvxBindingContextOwner view, System.Object target, IEnumerable1
bindingDescriptions, System.Object clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding
(IMvxBindingContextOwner view, System.Object target,
Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription
bindingDescription, System.Object clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription1[MonoTouch.UIKit.UITextField].Apply
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet2[CrossLightTouch.MyViewController,CrossLightTouch.ViewModels.MyViewModel].Apply
() [0x00000] in :0 at CrossLightTouch.MyViewController.ViewDidLoad ()
[0x0024f] in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/MyViewController.cs:81
at at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr) at
MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00008] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIWindow.g.cs:129
at CrossLightTouch.AppDelegate.FinishedLaunching
(MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary
options) [0x00042] in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/AppDelegate.cs:25
at at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain
(int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main
(System.String[] args, System.String principalClassName, System.String
delegateClassName) [0x0004c] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIApplication.cs:38
at CrossLightTouch.Application.Main (System.String[] args) [0x00008]
in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/Main.cs:17
By setting the IOS build options -> Link Behavior -> Don’t link , it works on device as expected, but the binary size has been doubled.
You can reproduce this issue with “N-39-CrossLight-Touch” sample.
Is there a fix or alternative for this?
If you don't already have a LinkerPleaseInclude file, copy the one from here into your project:
https://github.com/MvvmCross/MvvmCross/blob/6ab1baa9ca128921208efa994890039edf398474/TestProjects/Android-Support/Fragments/Example.Droid/LinkerPleaseInclude.cs
Also, add the following line to the Include(TextView text) method:
text.AfterTextChanged += (sender, args) => text.Text = "" + text.Text;
If that doesn't solve it, look for other events that may be used in the Mvx bindings and add those to the LinkerPleaseInclude file.
This issue is caused by the dynamic nature of Mvx binding on Android. Because the bindings are resolved at runtime, the Xamarin linker thinks the UI events they reference are not being used so they are removed from the final build. Adding references in the LinkerPleaseInclude file forces them to be included.
when using steema Teechart, its working fine in simulator, but application crashing when using in iphone,
its shows following error
System.NullReferenceException: Object reference not set to an instance of an object
at Steema.TeeChart.TChart.ApplyScroll () [0x00000] in :0
at Steema.TeeChart.TChart.m__0 (System.Object sender, System.EventArgs e) [0x00000] in :0
at MonoTouch.UIKit.UIScrollView+_UIScrollViewDelegate.Scrolled (MonoTouch.UIKit.UIScrollView scrollView) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIScrollView.g.cs:991
at MonoTouch.UIKit.UIScrollView.SetContentOffset (PointF contentOffset, Boolean animated) [0x00010] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIScrollView.g.cs:208
at Steema.TeeChart.TChart.Draw (RectangleF rect) [0x00000] in :0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at CropManageriPhone.Application.Main (System.String[] args) [0x00000] in /Users/vss1/VSS Projects/CP Live/CropManageriPhone04022013/CropManageriPhone/Main.cs:17
and We are using monotouch version 6.0.4
i found solution for this,
i set ZoomScrollStyle for the chart control,
_controller.chart.Aspect.ZoomScrollStyle=Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;
here is my Code
public int GetUsersSqlCount()
{
// Here i get the Error
return this.GetUsersSql().Count();
}
public IEnumerable<CsUser> GetUsersSql()
{
return (from x in this._storage.CsUsers
join y in this._storage.CeMitarbs on x.MitNr equals y.MitNr
select x).OrderBy(x => x.KurzZch);
}
I get the following Error:
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method 'System.Linq.Enumerable:<ToLookup`2>m__5A<Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CeMitarb, System.Nullable`1<int>> (Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CeMitarb)' while running with --aot-only.
at System.Linq.Enumerable.ToLookup[CeMitarb,Nullable`1,CeMitarb] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector, IEqualityComparer`1 comparer) [0x00079] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2966
at System.Linq.Enumerable.ToLookup[CeMitarb,Nullable`1] (IEnumerable`1 source, System.Func`2 keySelector, IEqualityComparer`1 comparer) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2934
at System.Linq.Enumerable+<CreateJoinIterator>c__Iterator18`4[Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser,Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CeMitarb,System.Nullable`1[System.Int32],Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser].MoveNext () [0x00023] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:1157
at System.Collections.Generic.List`1[Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser]..ctor (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.ToArray[CsUser] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at System.Linq.QuickSort`1[Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser]..ctor (IEnumerable`1 source, System.Linq.SortContext`1 context) [0x00000] in <filename unknown>:0
at System.Linq.QuickSort`1+<Sort>c__Iterator2F[Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CsUser].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Count[CsUser] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at CSMobile.Logic.Forms.Login_Dal.GetUsersSqlCount () [0x00000] in /Volumes/Mobile2011/Mobile 2011/trunk/WinCE/CSMobile/CSMobile.Logic/Forms/Login.Dal.cs:38
at CSMobile.Logic.Forms.Login_Logic.GetUsers () [0x0001f] in /Volumes/Mobile2011/Mobile 2011/trunk/WinCE/CSMobile/CSMobile.Logic/Forms/Login.Logic.cs:198
at CSMobile.Logic.Forms.Login_Logic.Anmelden2 (Int32 selectedProduct) [0x00050] in /Volumes/Mobile2011/Mobile 2011/trunk/WinCE/CSMobile/CSMobile.Logic/Forms/Login.Logic.cs:416
at CSMobile.UI.Login.Logic_LoginStepCompleted (Login_StepResult result) [0x0003e] in /Volumes/Mobile2011/Mobile 2011/trunk/IOS/CSMobile/CSMobile.UI/Forms/Login.cs:325
at CSMobile.Logic.Forms.Login_Logic.Anmelden1 () [0x00084] in /Volumes/Mobile2011/Mobile 2011/trunk/WinCE/CSMobile/CSMobile.Logic/Forms/Login.Logic.cs:364
at CSMobile.UI.Login.StartLogin () [0x00000] in /Volumes/Mobile2011/Mobile 2011/trunk/IOS/CSMobile/CSMobile.UI/Forms/Login.cs:75
at CSMobile.UI.Login.Pad_Start_TouchUpInside (MonoTouch.Foundation.NSObject sender) [0x00000] in /Volumes/Mobile2011/Mobile 2011/trunk/IOS/CSMobile/CSMobile.UI/Forms/Login.cs:235
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34
at CSMobile.UI.Application.Main (System.String[] args) [0x0000a] in /Volumes/Mobile2011/Mobile 2011/trunk/IOS/CSMobile/CSMobile.UI/Main.cs:18
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: Attempting to JIT compile method 'System.Linq.Enumerable:<ToLookup`2>m__5A<Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CeMitarb, System.Nullable`1<int>> (Genesis.DataAccess.Schema.Mobile.V1.Wrapper.CeMitarb)' while running with --aot-only.
I think this limitation here is actually due to Generic Virtual Methods - http://docs.xamarin.com/ios/about/limitations#Generic_Virtual_Methods
There's a discussion of a very similar problem on the mailing list:
http://monotouch.2284126.n4.nabble.com/LINQ-JIT-error-again-td3800970.html;cid=1338984263803-35#a3800169
It didn't sound like that thread found a solution
It might be worth contacting Xamarin support directly on this one. http://bugzilla.xamarin.com/
Generics are a bit weird on MonoTouch due to AOT compilation. A true runtime / JIT is disallowed in iOS, so it must compile everything ahead-of-time.
In this particular case, your method which returns IEnumerable<CsUser> is most likely the culprit. Generic interfaces cause problems. Try changing your return type to a List<CsUser> or any other concrete class that implements IEnumerable<CsUser>.
OrderBy is known to fail in this scenario. This appears to be fixed in MonoTouch version 2.10 but unfortunately if you're using an engine like Unity, that only ships with 2.6 currently (as of 4.3.x).
https://bugzilla.xamarin.com/show_bug.cgi?id=2155#c11
I don't know a convenient solution for Xamarin at the moment.
However there is such a solution for Unity 3D.
You can try LINQ to iOS. It's a custom implementation of LINQ to Objects extension methods that works on iOS without JIT-compile errors. If you're using Xamarin you may try to take .dll from LINQ to iOS and use it in your project. After all, Xamarin and Unity both use Mono compiler.