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.
Using NSLayoutConstraint.Create with NSLayoutAttribute.NoAttribute as the value of attribute2 causes a run-time exception as follows:
"MonoTouch.Foundation.MonoTouchException has been thrown
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Unknown layout attribute"
NSLayoutAttribute.NoAttribute should map to NSLayoutAttributeNotAnAttribute in Objective-C, which is supposed to be supported by constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant: (the Obj-C method that NSLayoutConstraint.Create maps to).
Additionally, it would be nice if were possible to pass null as the value of view2 in NSLayoutConstraint.Create (the equivalent of passing nil as the value of view2 in constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:).
You're getting the "Unknown layout attribute" because you're not passing null for the second view - so making it possible to pass null for the second view makes the error go away too.
There is an ugly workaround you can use until this fix is included in a release: pass a disposed NSObject instead of null (the important part is that its Handle must be IntPtr.Zero).