Declined
Last Updated: 26 Apr 2023 17:17 by Stephen
Stephen
Created on: 26 Apr 2023 16:40
Category: UI for .NET MAUI
Type: Bug Report
0
RadDataForm throws null errors on display before anything happens

I have three RadDataForms in my login workflow. I have tried all of the various CommitModes and ValidationModes to prevent this error, but nothing seems to prevent these errors from manifesting.

I have a data form that has two fields: Username and Password. When this form is FIRST displayed, what appears to be validation errors (formatted error log output):



----------------------------------
2023-04-26 09:22:18.9231 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------
----------------------------------
2023-04-26 09:22:18.9330 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------

Then, I have a different RadData form that has five fields, First Name, Second Name, Email Address, Password and Password Confirmation. This leads to:

----------------------------------
2023-04-26 09:22:46.6821 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------
----------------------------------
2023-04-26 09:22:46.6821 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------
----------------------------------
2023-04-26 09:22:46.7018 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------
----------------------------------
2023-04-26 09:22:46.7018 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------
----------------------------------
2023-04-26 09:22:46.7174 WARN  
  Call site:         BindingDiagnostics.SendBindingFailure
  Method name:       Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics.SendBindingFailure
  Line:              0
  Exception Type:    
  Exception Message: 
  Stack Trace:    
  Additional Info:   '(null)' cannot be converted to type 'System.Boolean'
----------------------------------

These errors are all encountered on the form's first load. Nothing has been entered into any field. No call to any validation methods is made. 

Here is how my general data form configuration is done:


<telerik:RadDataForm
    x:FieldModifier="public"
    x:Name="SignUpForm"
    Grid.Row="0"
    CommitMode="Explicit"
    Loaded="SignUpFormOnLoaded"
    Margin="0,5,0,0"
    Style="{StaticResource DataFormStyle}"
    ValidationMode="Explicit">

I have attached the three classes I use as the binding context. I have tried None, Explicit, and LostFocus as settings for the two modes and it has no effect. While these errors look harmless and the form does provide error-checked data upon validation, I simply hate having any unnecessary errors in my log files.

What can I do to prevent these errors?

Thanks!

Steve

2 comments
Stephen
Posted on: 26 Apr 2023 17:17

Thank you Lance! I was considering filtering the errors, but declined to do so until I understood the precise nature of the bug. If fixing it (other than filtering) by some configuration that I could do, that's what I was looking to nail down.

Thanks! Steve

ADMIN
Lance | Senior Manager Technical Support
Posted on: 26 Apr 2023 17:04

Hi Stephen,

Thank you for the very through report and attachments! What you're seeing are not real errors and can be ignored. Let me explain.

These specific warnings are coming from the Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics namespace about bindings... they're are not real errors. You can learn more about this XAML diagnostics feature of VS2022 here => XAML data binding diagnostics - Visual Studio (Windows).

This problem occurs even when everything is correctly configured, for example when we use Content attribute in a control that doesn't exactly match the name "Content".  Unfortunately, I am not aware of any way to configure the Xaml Binding Diagnostic tool in a way that avoids this misunderstanding when it's okay that a value can be null at first. Microsoft knows this, and is why they're flagged as warnings and not errors.

Although I may seem to be complaining, this tool is extraordinarily useful for native XAML projects like WPF, UWP and WinUI because it can catch errors at compile time instead of failing at runtime (after reflection). However, for .NET MAUI XAML, its mostly an annoyance.

Moving Forward

I completely understand that you do not like having these kinds of useless warnings in your logs. So, until this is fixed by Microsoft, my recommendation would be to add a log filter that excludes any warning from XamlDiagnostics.

The first part of this answer on StackOverflow will show you how to setup a logging filter in a .NET MAUI project https://stackoverflow.com/a/71715568/1406210 (skip the android struff, only the first part is relevant).

For example, it might look like this

Further Assistance

You've opened this as a Feedback Portal bug report instead of a Support Ticket, so I am forced to change the status to Declined. If you would like to continue having a conversation about techniques for handling Xaml diagnostics, please open a new Technical Support Ticket instead of a Feedback Portal item. Go to your Support Center, click "Contact Us" then "Technical support", we'll be happy to help where we can.

Regards,
Lance | Manager Technical Support
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.