unrecognized selector sent to instance 0x101b3c3c0 error on using async with button click event

ranju_ranju_ Member ✭✭

I am trying to call an async method from button click event. I am using below code
public override void ViewDidLoad()
{
base.ViewDidLoad();
btnSaveRecord.TouchUpInside += async (Object sender, EventArgs e) =>
{
await RegisterUserAsync();
};
}

But it's throwing below exception

Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[SqlDBController BtnSaveRecord_TouchUpInside:]: unrecognized selector sent to instance 0x101b3c3c0
Native stack trace:
    0   CoreFoundation                      0x000000018a318edc <redacted> + 252
    1   libobjc.A.dylib                     0x00000001894e9a40 objc_exception_throw + 56
    2   CoreFoundation                      0x000000018a231c24 <redacted> + 0
    3   UIKitCore                           0x00000001b721ccd8 <redacted> + 280
    4   CoreFoundation                      0x000000018a31e7dc <redacted> + 1412
    5   CoreFoundation                      0x000000018a32048c _CF_forwarding_prep_0 + 92
    6   UIKitCore                           0x00000001b71f0bd4 <redacted> + 96
    7   UIKitCore                           0x00000001b6c7e48c <redacted> + 80
    8   UIKitCore                           0x00000001b6c7e7ac <redacted> + 440
    9   UIKitCore                           0x00000001b6c7d7ac <redacted> + 568
    10  UIKitCore                           0x00000001b722a32c <redacted> + 2472
    11  UIKitCore                           0x00000001b722b590 <redacted> + 3156
    12  UIKitCore                           0x00000001b720a88c <redacted> + 340
    13  UIKitCore                           0x00000001b72d90f8 <redacted> + 1620
    14  UIKitCore                           0x00000001b72dbaf0 <redacted> + 4740
    15  UIKitCore                           0x00000001b72d45e0 <redacted> + 152
    16  CoreFoundation                      0x000000018a2a91f0 <redacted> + 24
    17  CoreFoundation                      0x000000018a2a9170 <redacted> + 88
    18  CoreFoundation                      0x000000018a2a8a54 <redacted> + 176
    19  CoreFoundation                      0x000000018a2a3920 <redacted> + 1040
    20  CoreFoundation                      0x000000018a2a31f0 CFRunLoopRunSpecific + 436
    21  GraphicsServices                    0x000000018c51c584 GSEventRunModal + 100
    22  UIKitCore                           0x00000001b71ef4c0 UIApplicationMain + 212
    23  App2                                0x00000001007d2868 App2 + 3909736
    24  App2                                0x000000010079516c App2 + 3658092
    25  App2                                0x000000010079512c App2 + 3658028
    26  App2                                0x000000010042f1a0 App2 + 94624
    27  App2                                0x00000001006f94c8 App2 + 3019976
    28  App2                                0x0000000101558050 mono_pmip + 24712
    29  App2                                0x00000001015c4f2c mono_pmip + 470884
    30  App2                                0x00000001015ca1e8 mono_pmip + 492064
    31  App2                                0x000000010153ee58 App2 + 17985112
    32  App2                                0x000000010166e258 _Z9__isctypeim + 47160
    33  App2                                0x000000010042f098 App2 + 94360
    34  libdyld.dylib                       0x0000000189d62bb4 <redacted> + 4
 occurred

Can anyone please guide me where I am doing wrong?

Thanks

Sign In or Register to comment.