Note that there are some explanatory texts on larger screens.

plurals
  1. POXamarin SKPaymentQueue AddPayment throwing exception
    primarykey
    data
    text
    <p>In my Xamarin app when I call this method</p> <pre><code>private void MakePayment (SKProduct product) { SKPayment payment = SKPayment.PaymentWithProduct (product); SKPaymentQueue.DefaultQueue.AddPayment (payment); } </code></pre> <p>I get this error:</p> <blockquote> <p>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).</p> </blockquote> <p>I'm not sure if I have something configured wrong or there is an issue in my code or Xamarin.</p> <p>Here's the code for the Observer</p> <pre><code>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) { } } </code></pre> <p>Here is the full stack trace:</p> <pre><code>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&amp; 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&amp; 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&amp;) 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 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload