CSLALight QueryCompleted consuming non-null exception

CSLALight QueryCompleted consuming non-null exception

Old forum URL: forums.lhotka.net/forums/t/6966.aspx


Jack posted on Tuesday, May 19, 2009

Rocky,

There is some logic in the QueryCompleted that is consuming exceptions - the note says it is for null reference exceptions but I am getting exceptions in there that are non null.  I'm using the Microsoft CAL and if an injected view fails to initialize (say a AG_E_PARSER_BAD_TYPE Error from badly formed XML) I get a Microsoft.Practices.Unity.ResolutionFailedException  which is then basically consumed and never rises out of there.  I'm assuming its due to the async call from the dataprovider which is completing after the failed creation after the view/usercontrol.

Just a FYI - A this point it isn't an issue as my UI is blank so I know something is wrong and I can see in the debugger but I'm sure it could hide something.

I'm running the 3.6.3 build.

jack

private void QueryCompleted(object sender, EventArgs e)
    {
      IDataPortalResult eventArgs = e as IDataPortalResult;
      SetError(eventArgs.Error);
      SetObjectInstance(eventArgs.Object);
      try
      {
        OnDataChanged();
      }
      catch (Exception ex)
      {
        // Silverlight seems to throw a meaningless null ref exception
        // and during page load there are possible timing issues
        // where these events may cause non-useful exceptions
        // and this is a workaround to ignore the issues
        var o = ex;
      }
      RefreshCanOperationsValues();
      this.IsBusy = false;
    }

RockfordLhotka replied on Tuesday, May 19, 2009

I'm not sure this would ever cause you an actual problem though.

This doesn't prevent normal page load exceptions like you are talking about. It merely prevents the raising of the DataChanged event from causing the data provider to fail.

So I suppose it could make debugging harder in one narrow case: where you have a custom control that is handling DataChanged, and in your event handler you have a scenario where an exception is thrown. In that one case you'd lose valuable information, because your event handler's exception would be swallowed.

I suspect that is a rare scenario (though I could be wrong).

But it is also possible that the null ref exception was an artifact of SL 2.0 beta, or maybe SL 2.0 and is gone in SL 3.0?

Copyright (c) Marimer LLC