Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
Stei #1
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Subject: Possible bug in UWP (Windows 10) when creating group chat
I'm using Matrix XMPP with my Xamarin Forms app. The code for both Android and UWP is the same (in regards to the code that handles XMPP functionality).

Here is the code that gives the error in UWP (but works in Android):

  1. var xdata = query.XData;
  2. var xDataResult = new Matrix.Xmpp.XData.Data { Type = Matrix.Xmpp.XData.FormType.Submit };
  3.  
  4. foreach (var field in xdata.GetFields())
  5. {
  6.     var retField = new Matrix.Xmpp.XData.Field();
  7.     retField.Type = field.Type; // The error is occurring here
  8.     retField.Var = field.Var;
  9.  
  10.     if (field.Var == "muc#roomconfig_roomname")
  11.         retField.AddValue("My Testing room");
  12.     else
  13.         retField.AddValues(field.GetValues().ToArray());
  14.  
  15.     xDataResult.AddField(retField);
  16. }

When trying to access the Field object's Type property, it throws a null reference error on UWP.

Even when looking at retField.Type in the debugger, it also says NullReferenceException, which is strange because I am setting that property, not getting it.
This post was edited on 2016-11-17, 10:43 by Alex.
Edit reason: added csharp code formatter
Avatar
Stei #2
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
As you can see, it says retField.Type threw an exception.

and in the 'field' variable, it is
  1. <field var="muc#roomconfig_roomname" type="text-single" label="Natural-Language Room Name" xmlns="jabber:x:data">
  2.  <value />
  3. </field>

as you can see, the 'type' is there, but it also says null reference exception.
The author has attached one file to this post:
strangeerror.jpg 7.4 kBytes
You have no permission to open this file.
This post was edited on 2016-11-17, 12:21 by Alex.
Avatar
Alex #3
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  • Which MatriX version number are you using?
  • On which platform? Which NuGet exactly for UWP?

I added a unit test for this and it passes without problems here:

  1. [Test]
  2. public void TestFieldTypeTextSingle()
  3. {
  4.     string xml = @"<field var='muc#roomconfig_roomname' type='text-single' label='Natural-Language Room Name' xmlns='jabber:x:data'/>";
  5.  
  6.     var el = XmppXElement.LoadXml(xml);
  7.  
  8.     el.Should().BeOfType<Field>();
  9.  
  10.     var field = el as Field;
  11.     field.Type.Should().Be(FieldType.TextSingle);
  12. }

Alex
This post was edited on 2016-11-17, 11:05 by Alex.
Avatar
Stei #4
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Matrix.WinRT.Uni 2.0.0.16, which has the error
Matrix.Xamarin.Android 2.0.0.17, which works
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
OK, we will investigate and come back to you.

Alex
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
thanks for reporting, there is Matrix.WinRT.Uni 2.0.0.22 which should fix this.

Alex
Avatar
Stei #7
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Thank you for fixing it so fast. I updated to the new version and it works fine now.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: