xamarin.ios - Exception System.InvalidCastException when calling a method bound with btouch that returns an object. MonoTouch bug? -
I'm trying to force Objective-C library types using btouch. I have managed to compile my API definition file with btouch and have successfully called methods that do not return any parameters or return the original parameters such as string or integer. However, when I try call methods which are the API definition file Returns the instance objects for other classes as defined in, I get an exception System.InvalidCastException is thrown in The list, which is UltraliteManager section of the OpenConnection method throws when calling from a Monochauc project this exception. This Objective-header file: This is the implementation of Objective-C (brief to show only the relevant implementation): and this is the API definition file: I have found that if I get the zero from the implementation of Open Connection (i.e. return connwrap; return nil; / em>) So the method gives without an exception throw. So, I feel that this exception has to be done with returning the ultralight conunction object to Monochoch. Does anyone know about this problem, and how can I solve it? I have managed to solve this problem and this is actually a bug in Monochoch. My work was to call btouch with the outdir parameter set and then to include the C # files generated in my project, instead, instead of doing it: btouch ultralite.cs enum.cs I did: btouch ultralite .cs enum.cs -outdir =. This file has two folders ObjCRuntime and Ultralite (name of my name). I removed ultralite.dll from the references of my project, and instead these two directories were copied and included the files, which are generated btouch. As reference, C # files instead of DLL, the OpenConnection method specified in my question was executed properly and returned the connection object. I have never made any changes to my purpose - the cover library, neither the API definition file, so it certainly seems a bug in btouch. Or maybe I was missing some other essential reasoning btouch in my original call, maybe someone from Monochoch could put some light on it. But, the lower line, my library is imported at the end and works correctly in Monochoch :) I hope this information will be helpful to any other person who faces this problem Are there.
#import & lt; Foundation / Foundation. H & gt; @interface ultralight connection: NSObject {@private void * ulconnection; } - (id) initWithULConnection: (Zero *) connect; - (zero) DLok; - (zero) off; - (zero) executeStatement: (NSString *) SQL; @end @ Interface Ultralight Manager: Start NSObject {} + (Zero); + (Zero) Finney; + (Ultrasonic connection *) openConnection: (NSString *) connection perm; @end
@implementation UltraliteConnection - (ID) initWithULConnection: ( Zero *) Connect {[Super Init]; Synchronization = connect [Self retention]; Self return; } - (zero) Delok [[Super Delooc]]; } - (zero) close {ULError error; (ULConnection *) Light relationship) - & gt; Close (& amp; Error); [Self release]; } @end @implementation UltraliteManager + (UltraliteConnection *) openConnection: (NSString *) Connection {ULError Error; UL Connection * Cobbes; Insert ultralight connection *; Connbase = ULDatabaseManager :: OpenConnection ([connectionParms UTF8String], and error, NULL); Connwrap = [[UltraliteConnection alloc] initWithULConnection: connbase]; [Conference release]; Return conference; } @end
Mono touch. Using the Foundation; Namespace Ultralight {[Base type (typeb (NSOZ) interface Interface ultralight connection [[Export ("off")] Zero shutdown (); [Export ("executeStatement:") Zero ExecuteStatement (string SQL); } [BaseType (NSOBYE)] InterraliteManager interface [[Static, Export ("Initiative")] string initialize (); [Static, Export ("Finney")] Zero Fini (); [Static, Export ("Open Connection:")] Ultrasonic Connection Open Connection (String Connection Perm); }}
Comments
Post a Comment