In my Xamarin Mac project, I have set up a NSTableView programmatically. I have a custom NSTableHeaderCell that I am using for the column header cells. For some reason on some machines, it's throwing an error
Failed to marshal the Objective-C object 0x121f77e90 (type: XXXTableHeaderCell). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'XXXTableHeaderCell' does not have a constructor that takes one IntPtr argument).
I know this can be thrown if you're loading from a nib/xib, but I'm building it all in code. I also know it can happen if your managed object gets GC'd, but the header cell and column objects should be held on to by the table view.
Putting in an empty constructor that takes an IntPtr seems to fix the issue, but I'm concerned that it's creating a new object when it should be using something that already exists (or should still, at least).
Am I missing something in how these are held?
The last part of the error likely contains the key:
'XXXTableHeaderCell' does not have a constructor that takes one IntPtr argument
Did you expose a constructor that takes an IntPtr (that calls base with that pointer)? That is used in marshaling between managed and native code.