[Mono-osx] Invalid cast exception during delegate callback

Chris Waldron chris.waldron at booktrack.co
Mon Jan 23 20:21:59 UTC 2012


I'm getting a System.InvalidCastException during a delegate callback from
monomac

Below is the Exception message and stack trace ...

Exception Message ...

Cannot cast from source type to destination type.

Stack Trace

  at (wrapper managed-to-native) object:__icall_wrapper_mono_
object_castclass (object,intptr)
  at
MonoMac.ObjCRuntime.NSObjectMarshaler`1[MonoMac.StoreKit.SKProductsResponse].MarshalNativeToManaged
(IntPtr handle) [0x00000] in
/cvs/monomac/src/ObjCRuntime/NSObjectMarshaler.cs:33
  at (wrapper native-to-managed)
object:[MonoMac.StoreKit.SKProductsRequest+_SKProductsRequestDelegate:Void
ReceivedResponse(MonoMac.StoreKit.SKProductsRequest,
MonoMac.StoreKit.SKProductsResponse)]
(MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.StoreKit.SKProductsRequest,MonoMac.StoreKit.SKProductsResponse)

It seems to be failing in MonoMac when trying to call the
SKProductsRequestDelegate method ...


        [Export ("productsRequest:didReceiveResponse:")]
        public abstract void ReceivedResponse (SKProductsRequest request,
SKProductsResponse response);

It is failing with a cast error but I don't know why.  The cast error would
to me indicate that the generated signature doesn't match what's actually
in MacOSX StoreKit.

This is the definition in SKProductsRequest.h

//
//  SKProductsRequest.h
//  StoreKit
//
//  Copyright 2009 Apple, Inc. All rights reserved.
//

#import <StoreKit/SKRequest.h>



@class SKProductsRequest, SKProductsResponse;

@protocol SKProductsRequestDelegate <SKRequestDelegate>

@required
// Sent immediately before -requestDidFinish:
- (void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response;

@end


// request information about products for your application
NS_CLASS_AVAILABLE(10_7, NA)
@interface SKProductsRequest : SKRequest {
@private
    id _productsRequestInternal;
}

// Set of string product identifiers
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers;

@property(assign) id <SKProductsRequestDelegate> delegate;

@end


NS_CLASS_AVAILABLE(10_7, NA)
@interface SKProductsResponse : NSObject {
@private
    id _internal;
}

// Array of SKProduct instances.
@property(readonly) NSArray *products;

// Array of invalid product identifiers.
@property(readonly) NSArray *invalidProductIdentifiers;

@end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20120124/4f8c46e4/attachment.html>


More information about the Mono-osx mailing list