locked
Exception 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown. Unified API Binding RRS feed

  • Question

  • User25507 posted

    I built an API Binding project to the Magtek SDK (libMTSCRA.a), and was able to get that to build an assembly that I can reference in my iOS project. I am able to create the object and call a couple of methods on it, but when I call MTSCRA.OpenDevice() I am getting this stack trace from the Mono debugger:

    Exception of type 'Foundation.YouShouldNotCallbaseInThis_Method' was thrown.

    Unhandled Exception:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

    2016-06-17 11:49:01.265 CDAMobileMarketingAppiPadKiosk[880:1071233] Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Foundation.YouShouldNotCallbaseInThisMethod: Exception of type 'Foundation.YouShouldNotCallbaseInThisMethod' was thrown. at CDA.MobileMarketingApp.Magtek.MTSCRAEventDelegate.OnDeviceConnectionDidChange (nuint deviceType, Boolean connected, Foundation.NSObject instance) [0x00006] in :0 at CDA.MobileMarketingApp.iPadKiosk.DependencyServices.MagtekDynamoiOS.OnDeviceConnectionDidChange (nuint deviceType, Boolean connected, Foundation.NSObject instance) [0x0002d] in C:\TFS-CDA\MobileMarketingApp\CDA.MobileMarketingApp\iPadKiosk\DependencyServices\MagtekDynamoiOS.cs:63 at (wrapper managed-to-native) ApiDefinition.Messaging:boolobjcmsgSend (intptr,intptr) at CDA.MobileMarketingApp.Magtek.MTSCRA.OpenDevice () [0x0001c] in :0 at CDA.MobileMarketingApp.iPadKi osk.DependencyServices.MagtekDynamoiOS..ctor () [0x0004a] in C:\TFS-CDA\MobileMarketingApp\CDA.MobileMarketingApp\iPadKiosk\DependencyServices\MagtekDynamoiOS.cs:30

    Attached the files from the Binding project.

    Friday, June 17, 2016 3:59 PM

Answers

  • User25507 posted

    Got this working. Their header file they provided with their SDK had a typo - different name than what is the in .a file. MTSCRAEventDelegate is in the header, but the Objective-C Class name is MTSCRADeviceDelegate.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, June 17, 2016 6:45 PM

All replies

  • User12211 posted

    I think:

    // @interface MTSCRA : NSObject <NSStreamDelegate>
    [BaseType(typeof(NSObject))]
    interface MTSCRA
    

    Should be:

    // @interface MTSCRA : NSObject <NSStreamDelegate>
    [BaseType(typeof(NSObject))]
    interface MTSCRA : NSStreamDelegate
    

    I don't know if that's causing your issue or not, but based on the Binding Types Reference, that seem like the correct way to declare that interface.

    Friday, June 17, 2016 6:04 PM
  • User25507 posted

    Thanks @DaveHunt yeah I put the : NSStreamDelegate back. I have been trying every possible thing to try and get this to work with no luck. I took out the calls to base.OnDeviceConnectionDidChange() in my class that inherits MTSCRAEventDelegate which takes care of the error above, but now I'm getting this error when attempting to call OpenDevice():

    Wrapper type 'CDA.MobileMarketingApp.Magtek.MTSCRAEventDelegate' is missing its native ObjectiveC class 'MTSCRAEventDelegate'.

    2016-06-17 14:13:20.344 CDAMobileMarketingAppiPadKiosk[925:1087424] Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> ObjCRuntime.RuntimeException: Wrapper type 'CDA.MobileMarketingApp.Magtek.MTSCRAEventDelegate' is missing its native ObjectiveC class 'MTSCRAEventDelegate'. at Registrar.DynamicRegistrar.OnRegisterType (Registrar.ObjCType type) [0x002ff] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/DynamicRegistrar.cs:828 at Registrar.Registrar.RegisterTypeUnsafe (System.Type type, System.Collections.Generic.List1& exceptions) [0x010b5] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/Registrar.cs:1888 at Registrar.Registrar.RegisterTypeUnsafe (System.Type type, System.Collections.Generic.List1& exceptions) [0x000d6] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/Registrar.cs:1443 at Registrar.Registrar.RegisterType (System.Type type, Syst em.Collections.Generic.List`1& exceptions) [0x00011] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/Registrar.cs:1062 at Registrar.DynamicRegistrar.Register (System.Type type) [0x00002] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/DynamicRegistrar.cs:1124 at ObjCRuntime.Class.Register (System.Type type) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/ObjCRuntime/Class.cs:161 at ObjCRuntime.Class.GetHandle (System.Type type) <0x100d54e60 + 0x00013> in :0 at Foundation.NSObject.AllocIfNeeded () [0x00015] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/Foundation/NSObject2.cs:474 at Foundation.NSObject..ctor (Foundation.NSObjectFlag x) [0x00006] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/Foundation/NSObject2.cs:113 at CDA.MobileMarketingApp.Magtek.MTSCRAEventDelegate..ctor () [0x00000] in :0

    Friday, June 17, 2016 6:13 PM
  • User25507 posted

    Got this working. Their header file they provided with their SDK had a typo - different name than what is the in .a file. MTSCRAEventDelegate is in the header, but the Objective-C Class name is MTSCRADeviceDelegate.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, June 17, 2016 6:45 PM
  • User12211 posted

    @JonHunt,

    Actually, the MTSCRAEventDelegate is a protocol. Protocols should be marked with the:

    [Model][Protocol]
    

    attribute. I'm not sure your change actually fixed the problem. I would change it back and add the model attribute:

    // @protocol MTSCRAEventDelegate <NSObject>
    [BaseType(typeof(NSObject))]
    [Model][Protocol]
    interface MTSCRAEventDelegate
    

    and see what happens. Either way, that attribute should be specified.

    BTW, my father's name is John, so this is kind of bizarre for me ;-)

    Friday, June 17, 2016 6:59 PM
  • User25507 posted

    Thanks for your help!

    Yes I added the Model attribute back as well and that made no difference. It really is the name of the @protocol from the header file doesn't match the name from the library .a file.

    Do you want to know something even more bizarre? My uncle's name is Dave Hunt! Haha.

    Friday, June 17, 2016 7:12 PM
  • User12211 posted

    @JonHunt said:

    Do you want to know something even more bizarre? My uncle's name is Dave Hunt! Haha.

    :smiley:

    Friday, June 17, 2016 7:26 PM
  • User63301 posted

    Hi, I am currently working to implement the same library as you. In case you got everything working would you mind sharing the final binding project? I am struggling with some compilation issues when using the IMTSCRAEventDelegate class/interface.

    Monday, August 22, 2016 10:38 AM