Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Importing NSPerformService

$
0
0

I've tried to import NSPerformService and got this so far:
[System.Runtime.InteropServices.DllImport("System/Library/Frameworks/AppKit.framework/Versions/C/AppKit")]<br /> static extern bool NSPerformService(string item, NSPasteboard pboard);

Unfortunately, when I call it I get System.Runtime.InteropServices.MarshalDirectiveException:

Type AppKit.NSPasteboard which is passed to unmanaged code must have a StructLayout attribute.

I realize that it is something about marshaling, so that probably NSPasteboard should be sent like IntPtr or something else, but I have no idea on how to do that (this thread contains the solution when this happens on the return value, but it can't be applied when the problem is in the argument: https://forums.xamarin.com/discussion/57248/type-foundation-nsdictionary-which-is-passed-to-unmanaged-code-must-have-a-structlayout-attribute).

I guess the answer would help to other people that might have similar problem in the future as there aren't too many threads regarding this and definitely not about this specific issue.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>