Forum Xamarin Xamarin.iOS

Strange Issue with TextField

EkkehardBeierEkkehardBeier DEUniversity ✭✭


I'm using a UITextField in a popup view (since several years) but since a while the App dies as soon as the text field is clicked (even if all event handlers are removed). It then fires an exception:

System.Exception: Failed to marshal the Objective-C object 0x125b19c80 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).

Being unable to debug/solve it directly, and as work-around, I tried to use a button/label with an Alert View and embedded text field, instead. But as soon as I present the alert view ctrl the same happens. Other controls in the same popup view work without any issues.

Any help is greatly appreciated. It's also possible to earn a few bucks here, I can provide access to the App code hosted on bitbucket. I'm a Xamarin.iOS dev since 2013 and usually solve my issues by myself, but here I'm kinda lost...

Thx ia


Best Answer


  • DimitrisDapontesDimitrisDapontes GRMember ✭✭


    I've got the same problem here. I've got a DialogViewController containing some elements. When I click some of them, the app crashes. The error message is the same Failed to marshal the Objective-C object 0x12be009f0 (type: UIView)...

    The only thing I can add is the stack trace that indicates that the exception occurs in BecomeFirstResponder method

    at (wrapper managed-to-native) ObjCRuntime.Messaging.bool_objc_msgSend(intptr,intptr)
    at UIKit.UIResponder.BecomeFirstResponder () [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
    at MonoTouch.Dialog.EntryElement.BecomeFirstResponder (System.Boolean animated) [0x00029] in /Users/builder/data/lanes/5944/64fece5f/source/xamarin-macios/external/MonoTouch.Dialog/MonoTouch.Dialog/Elements.cs:188

    PS. I' m working on Visual Studio 2017 and a Mac for the builds. The problem occurs only on physical devices, since the simulator is running without a problem.

  • EkkehardBeierEkkehardBeier DEUniversity ✭✭

    Same on my side, Device doesn't work, Simulator works fine.

  • ColeXColeX Member, Xamarin Team Xamurai

    Which popup view are you using ? Have you tried UIAlertController ? You can add textfield on it by the method AddTextField.

  • EkkehardBeierEkkehardBeier DEUniversity ✭✭

    This is what I tried as workaround. But exactly the same happened when I tried to present the alert controller

  • DimitrisDapontesDimitrisDapontes GRMember ✭✭

    I came across a post in the forum (it seems I cannot post any links here so I' ll just say that the post number is 20025) that describes the same error message. The difference there is that the IntPtr constructor is missing from a user-defined class, whereas in our situation the constructor is missing from UIView (a framework class). I tried adding a constructor with IntPtr in my DialogViewController, but unfortunately nothing changed. The app still crashes.

  • DimitrisDapontesDimitrisDapontes GRMember ✭✭
    edited June 2018

    Just to inform you : I've filed a test case on an existing github issue # 4254 on project xamarin-macios

    [I still cannot post any links]

  • DimitrisDapontesDimitrisDapontes GRMember ✭✭
    Accepted Answer
  • EkkehardBeierEkkehardBeier DEUniversity ✭✭
    thx and good luck
  • EkkehardBeierEkkehardBeier DEUniversity ✭✭

    Hi guys,

    seems this is fixed. Does anyone know when there will be a Xamarin.iOS update in the Release channel that provides the fix?

Sign In or Register to comment.