0
votes

I'm getting an exception on a Xamarin Forms content page with Xaml, on the initializecomponent method. The exception occurs on the generated xaml.gs page. I haven't changed any code form a working version. Maybe something upstream has changed. The exception message is ""

Value cannot be null. Parameter name: binding

stack trace: at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding, System.Boolean fromStyle) [0x00011] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:293 at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:117 at ....LoginPage.InitializeComponent () [0x00045] in ...\obj\Debug\netstandard2.0\Views\Navigation\Login.xaml.g.cs:34 at FieldServices.LoginPage..ctor () [0x0002b] in ..\Views\Navigation\Login.xaml.cs:25

where occurrs:

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")] private void InitializeComponent() { global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(LoginPage)); email = global::Xamarin.Forms.NameScopeExtensions.FindByName(this, "email"); password = global::Xamarin.Forms.NameScopeExtensions.FindByName(this, "password"); loginButton = global::Xamarin.Forms.NameScopeExtensions.FindByName(this, "loginButton"); }

4
I should add the xaml previews fine in a xaml previewer, so I'm doubting its a xaml error - Patrick Goode
It seems there's something wrong with your binding part. Can you offer some code to specify more? Moreover, can you reproduce it on a new blank project? - Anonymous
This only occurs on this project. Its happening on any xaml page so I'm not sure what is being bound and where. Some xaml pages have no binding - Patrick Goode

4 Answers

0
votes

I rarely get this error when pulling code down. First, double-check that your code is fine. In this case, I would make sure all the bindings are named correctly with no typos.

In the event that you cannot find an error and are thoroughly convinced there is nothing wrong with the code, try steps like

  • Clean and Rebuild
  • Close your Visual Studio and restart it

Hopefully the error is solved as easy as this.

0
votes

On top of cleaning and rebuilding, manually delete all the obj and bin folders from your solution directory. Those xaml.gs files are generated files and sometimes they seem to not regenerate when they should.

0
votes

I'm getting an exception on a Xamarin Forms content page with Xaml, on the initializecomponent method. The exception occurs on the generated xaml.gs page. I haven't changed any code form a working version. Maybe something upstream has changed.

It is not reproduceable by myside, but per experience there are a few things you can try:

  1. Put your project in a short path like "C:\".
  2. Try a new blank project, see if the error occors.
  3. If none of the above works, you can try reinstalling Xamarin in your VS.
0
votes

This was solved due to my not linking a static resource that was declared in the xaml