Bug 40435 - Entry on UWP crashing with nullreference exception Xamarin.Forms V2.2.0-pre2
Summary: Entry on UWP crashing with nullreference exception Xamarin.Forms V2.2.0-pre2
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-04-15 14:04 UTC by FieldstrikeMobile
Modified: 2016-04-26 07:40 UTC (History)
4 users (show)

Tags: Windows ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
VERIFIED FIXED

Description FieldstrikeMobile 2016-04-15 14:04:44 UTC
I cant get a simple sample toghether that will replicate the bug but when using an Entry control on UWP it seems I am a

NullReferenceException

from this method:

    private void OnNativeTextChanged(object sender, TextChangedEventArgs args)
    {
      this.Element.SetValueCore(Entry.TextProperty, (object) this.Control.Text, BindableObject.SetValueFlags.None);
    }


I'd imagine this would need some defensive coding like UpdateFont()

    private void UpdateFont()
    {
      if (this.Control == null)
        return;
      Entry element = this.Element;
      if (element == null)
        return;

      ....
    }
Comment 1 FieldstrikeMobile 2016-04-15 14:59:23 UTC
For example if you look at the EditorRenderer on UWP it has the following method:

    private void OnNativeTextChanged(object sender, TextChangedEventArgs args)
    {
      Editor element = this.Element;
      if (element == null)
        return;
      BindableProperty property = Editor.TextProperty;
      string text = this.Control.get_Text();
      int num = 0;
      element.SetValueCore(property, (object) text, (BindableObject.SetValueFlags) num);
    }

and I imagine EntryRenderer needs to be coded in the same way
Comment 2 FieldstrikeMobile 2016-04-15 15:08:33 UTC
To clarify I know it is the OnNativeTextChanged method that is throwing the nullreferenceexception on UWP because of the stack trace
Comment 3 Samantha Houts [MSFT] 2016-04-19 07:17:45 UTC
Should be fixed in 2.2.0-pre3. Thank you!
Comment 4 Parmendra Kumar 2016-04-25 18:19:00 UTC
To verify this issue I have tried to reproduce this issue but not able to reproduce this issue.

Could you please provide me a small sample project? so that I can verify this issue efficiently. 

Thanks.
Comment 5 FieldstrikeMobile 2016-04-26 07:40:01 UTC
@Parnmendra I tested this with my application and I can verify that this bug is fixed in 2.2.0 pre 3
Comment 6 FieldstrikeMobile 2016-04-26 07:40:19 UTC
@Parnmendra I tested this with my application and I can verify that this bug is fixed in 2.2.0 pre 3