If a custom control throws an exception in its constructor the rendering process crashes with a NullPointerException when rendering on Android API level 23 (and 24).
Expected: the custom control exception should be caught and a red mock view displayed instead. http://screencast.com/t/RGDn3DE90ec8
Fixed in version 184.108.40.2060 (master)
Author: J??r??mie Laval
Commit: 223703b4652f4bdd40ac2d46814139964f87cfde (xamarin/md-addins)
Included in Commit: 7b59eb69bf4b518c00db3521ab3b5b4166046583 (mono/monodevelop)
- Create new Android project
- Create new custom view
- Fill `Initialize` method with a `throw new Exception ("foo")`
- Compile project
- Open Main.axml in designer
- Drop element in layout
+ restart Xamarin Studio and open the solution and layout with the faulty custom control already in it.
I have checked this issue with the latest Cycle 8 builds:
And I have observed that the issue still exist, as after adding the custom view in the designer, when close and re-open the android designer, exception appears.
Below are the steps I followed:
1. Create new Android project
2. Create new custom view
3. Fill "Initialize" method with a "throw new Exception ("foo");"
4. Compile project
5. Open Main.axml in designer
6. Drop CustomView element in layout
7. Close the Main.axml
8. Again open Main.axml
Re-opning this issue w.r.t Cycle 8. Once the fix is merged in Cycle 8, I will verify and close this issue.
This has been backported to cycle8.
Included in monodevelop: 2b65e9bec34bade4893b7a28b5cfd5836db6e4db
I have checked this issue with latest C8 XS 220.127.116.1168 and observed that now this issue is working fine and showing the expected behavior. Now custom control mock view is displaying when rendering the designer on Android API level 23 (and below also) and the custom control exception is showing in IDE log.
Hence closing this issue.