Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
Beaker #1
Member since Mar 2010 · 7 posts
Group memberships: Members
Show profile · Link to this post
Subject: Null exception in IqFilter.SendIq
The following code works on the desktop. It's purpose is to check if the user has been subscribed to a node more than once. If they have, all of those subscriptions are removed and a single new subscription is created.  The code throws a null exception at the SendIQ call.

foreach (XElement element in subs.Elements(ps + "subscription"))
                {
                    Iq iq2 = new Iq();
                    iq2.To = pubsubService;
                    iq2.From = UserJid;
                    iq2.Type = IqType.set;
                    string subid = element.Attribute("subid").Value;
                    Unsubscribe unsub = new Unsubscribe();
                    unsub.Node = editNode;
                    unsub.Jid = UserJid;
                    unsub.SetAttribute("subid", subid);
                    iq2.Query = new XElement(ps + "pubsub", unsub);
                    IqFilter myFilter = new IqFilter(_xmppClient);
      *****     myFilter.SendIq(iq2, MyUnscubscribeResult,null);
                }
               
SendIQ xml

<iq to="pubsub.real" from="bob@real" type="set" xmlns="jabber:client">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <unsubscribe node="EditNode" jid="bob@real" subid="n1gbwYqLQyH4ILW71fVrk19MJATXnnqna0Wl0PpY" />
  </pubsub>
</iq>


The SendIQ call does not result in an _xmppClient_OnError message the stack trace follows

Value can not be null.
Parameter name: key

at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.Insert(String key, ? value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(String key, ? value)
   at Matrix.IqFilter.SendIq(Iq iq, EventHandler`1 callback, Object state)
   at RrISE.XMPP.CF.XmppManager.MyCheckForSubscriptionResult(Object sender, IqEventArgs e)
   at Matrix.IqFilter.?(Object ?, IqEventArgs ?)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.Windows.Forms.Control.TASK.Invoke()
   at System.Windows.Forms.Control._InvokeAll()
   at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.ContainerControl.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Form.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)
   at System.Windows.Forms.Form.ShowDialog()
   at


Thanks
This post was edited on 2010-06-08, 17:20 by Beaker.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your Iq has no Id. Use GenerateId() to assign a unique Id to the Iq. The id is required with IQs, the IqFilter is using the Id to track incoming IQs and raising the callback.
Please let me know if this was the root of your problem.

Alex
Avatar
Beaker #3
Member since Mar 2010 · 7 posts
Group memberships: Members
Show profile · Link to this post
Thanks, that fixed. Is there a reason that this exact code seems to work fine on the desktop. On the desktop, the iq has no id but no error is thrown and the subscription is removed.
This post was edited on 2010-06-08, 19:49 by Beaker.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Beaker:
Thanks, that fixed. Is there a reason that this exact code seems to work fine on the desktop. On the desktop, the iq has no id but no error is thrown and the subscription is removed.

in MatriX the ids and callbacks get added to a collection. It looks like the .NET collection behaved different in CF than in the full framework. But in both cases you should get an error reply from the server and your MyUnscubscribeResult callback will never raise.

Alex
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: