No constructor found for … (System.IntPtr, Android.Runtime.JniHandleOwnership)

后端 未结 1 1776
梦如初夏
梦如初夏 2020-12-09 21:20

In the last few days I started getting the error above.
Not here and there, but everywhere. and in places I can\'t even put this weird constructor in, like the call-sta

相关标签:
1条回答
  • 2020-12-09 21:40

    From what I experienced, this can happens when an object is released from memory while your application is running. Then, for instance, if you go back to that page and the object needs to be recreated by Mono, you need to specify that constructor.

    The John Pryor answer you are referring to should be the answer to your problem. The important part is the following :

    So Mono for Android creates an instance of the appropriate type...via the (IntPtr, JniHandleOwnership) constructor, and generates an error if this constructor cannot be found.

    Once the (in this case) TextView constructor finishes executing, the LogTextBox's ACW constructor will execute, at which point Mono for Android will go "aha! we've already created a C# instance for this Java instance", and will then invoke the appropriate constructor on the already created instance. Meaning that for a single instance, two constructors will be executed: the (IntPtr, JniHandleOwnership) constructor, and (later) the (Context, IAttributeSet, int) constructor.

    I'd like to be a better help, but without any code snippet it's hard to tell. Try looking in object which implements the IOnClickListenerImplementorsee if you can add the constructor in the implementation of the listener.... Good luck

    0 讨论(0)
提交回复
热议问题