Forum Xamarin.Mac

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

ImageCaptureCore marshal issue when linking

AressemAressem GBMember ✭✭

Hi

I'm trying to resolve an issue with ImageCaptureCore. I have code that works OK when linking is set to "Don't Link", but if I set to "Link Framework SDKs" then I encounter a marshalling issue with one of the callbacks.

public override void DidAddItem(ICCameraDevice camera, ICCameraItem item)

When this is triggered, I get the following exception:

Unable to marshal the parameter #2 whose managed type is 'ImageCaptureCore.ICCameraItem' to managed. Additional information: Selector: cameraDevice:didAddItem: Method: MyApp.CameraDevice:DidAddItem (ImageCaptureCore.ICCameraDevice,ImageCaptureCore.ICCameraItem)

The inner exception is:

{System.MemberAccessException: Cannot create an instance of ImageCaptureCore.ICCameraItem because it is an abstract class at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Bin…}

Looking at the declaration of ICCameraItem, it's declared as:

[Register ("ICCameraItem", true)] public abstract class ICCameraItem : NSObject

(but there are no abstract methods defined)

As I say, this works fine if the linker is set to Don't Link, which suggests something is being ripped out in the linking stage - is there a missing [Preserve] attribute in the ICC code?

I'm a little sketchy on my understanding of the Objective-C bindings so there might be a really simple solution to this that I'm overlooking, but I've tried lots of things and haven't had much luck. Any help would be appreciated!

Thanks.

Best Answer

Answers

Sign In or Register to comment.