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 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 19772 [details]
I have been trying to get the XAML previewer to work on my machine, however, it will not render any object, claiming that it can't find the parameterless constructor for my object ( a generic page ).
The exact error message is "This control does not have a default parameterless constructor. It cannot be previewed unless it contains one."
Can you attach a sample that reproduces the problem?
This causes the issue:
<?xml version="1.0" encoding="utf-8" ?>
<Label Text="Hello, XAML!"
We'd need the implementation of the `Learn.MVVM.View.Page1` class, in a compilable project, to fully diagnose/resolve the issue.
I'm having the same issue. At some point (I guess after one of the Xamarin Studio updates) XAML Preview just stopped working in all my views with the same error message (although there is definitely default parameterless constructor present in them). It doesn't even work if I create a fresh empty ContentPage in my project.
Unfortunately, I can't reproduce this in a standalone manner. It works fine if I create a new solution and try to mimic my view class structure and project settings.
Forgot to mention: I use Xamarin Studio on Mac, not Visual Studio on Windows. But the error message is exactly the same.
If you can provide a sample project (or if you wish to privately share your actual project with us) we should be able to diagnose the issue.
Alternatively if you can provide the log files from a session where a xaml file failed to render we may be able to figure out the underlying issue from that.
How can I share my project privately?
We have a few options:
1) If you have a preferred way of hosting a zip of the project (dropbox etc) you could put it there and email us a link to it. We will let you know when we've downloaded it so you can remove it.
2) You can email it directly to me (same email address as I use in bugzilla) and I'll review the issue.
3) We can create a new private bug which you can upload the files to.
Option 1 leaves you in control of the availability of your data, which some people prefer. Option 2 also works well for small projects.
Dear Alan, I had this same issue when I upgraded my environment (versions bellow) and after a not so easy creativity exercise (because xamarin logs should help more, but it just show a inespecific XamarinFormsDefaultConstructorNotFoundException whithout indicates the target type of the exception) I discovery that my problem was generated by my App class (in the portable library).
Then, I simply added the parameterless constructor (to be used only by previewer):
It's important invoke the InitializeComponent method in parameterless constructor, otherwise we will get errors of static resources not found (if x:StaticResource is used).
Xamarin 22.214.171.1244 (73f58d6)
Xamarin.Android 126.96.36.199 (9578cdc)
Xamarin.iOS 10.4.0.123 (35d1ccd)
It's all, I hope I have helped!
That's definitely useful information. We've already improved this error message so it includes the actual type of the object, and will indicate that you need to call `InitializeComponent` too. This should ship as part of a future update. Thanks for the report!
You are welcome!
Great news, the xamarin is an amazing tool and improve the error messages is very important to help us to deal with this type of problems.