Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 711 [details]
Sample that can trigger bug
the attached project contains a MonkeyDocument : UIDocument
i'm trying to follow the 'subclassing notes' in the apple docs ~ in the simulator i can fake-write (ie.manually) the document and open it successfully, but *saving* always results in an NSObjectWrapped problem.
at MonoTouch.ObjCRuntime.Runtime.GetNSObject (intptr) <0x00083>
at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (intptr) <0x0001b>
at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (intptr) <0xffffffff>
at MonoTouch.UIKit.UIDocument.Save (MonoTouch.Foundation.NSUrl,MonoTouch.UIKit.UIDocumentSaveOperation,MonoTouch.UIKit.UIOperationHandler) <0x00107>
The code that causes the error is in the attachment MonkeyDocument.cs and MonkeyDocViewController.cs
EMAIL FROM MDI (for reference):
This seems to be a bug in our binding.
There are a couple of problems, I mapped the:
In a few places as "out NSError foo", and this seems to be causing some problems. The first problem is that we should probably have made this a "ref NSError foo" and not an out. The second problem seems to be that the monotouch_trampoline does not know how to cope with the refs or outs for NSErrors, although I thought we had support for this.
Replacing the API with IntPtr ptrToNSError makes the code not crash once, but then further invocations to Save fail (perhaps this is expected).
This problem is fixed, the MonoTouch code did not cope with ref/out parameters that were set to null.
The sample contains one problem: creating instances of NSError without an ErrorDomain creates half-baked NSError objects. I have added some error reporting to avoid this practice.
in this case, if you do not want to return an error, you should just assign null to the error return, do not use new NSError () alone