Skip to main content

Workflow error exists in HTML5 but not Silverlight viewer

Comments

8 comments

  • Permanently deleted user

    JD,

    Were you able to figure this out, I'm getting the exact error. It works fine in SL viewer and in the simulator but I get the error in HTML5.

    Thanks

    Pablo

    0
  • Permanently deleted user

    Unfortunately, no.

    0
  • Permanently deleted user

    Hi Folks,

    I think this error is due to a behavioral difference between the Silverlight and HTML5 viewers.

    The return type for a multiple-selection list box is a "List of objects".  Silverlight and WPF (the simulator) represent this as a generic List of Objects.  HTML5 represents it as an array of Objects.

    So, if you built your workflow with the Silverlight viewer, you would have been able to cast the return type from a form to a List<Object>.

    There should be a way to handle either viewer without a problem.  Both structures are enumerable so you should be able to either add their contents to a new array of known type, or convert them to a common type.  Off the top of my head, I don't know exactly how to do that, but we'll see if we can find someone to provide some answers.

    Regards,

    -Malcolm

    0
  • Ryan Cooney

    You can use the Cast<T> activity to cast to either:

    • System.Collections.Generic.IList<System.Object>

    • System.Collections.Generic.IEnumerable<System.Object>

    The help documentation does indicate this on the Form Items page, but it isn't very obvious.

    --Ryan

    0
  • Permanently deleted user

    Thanks Ryan/Malcolm. I apprecaite the help!

    0
  • Permanently deleted user

    I get that you can cast to either but the issue is using the same workflow for either SL or HTML5.

    My solution at the moment is to use an If statement to check the type, if the result is System.Object[] then it's coming from HTML5.

    IF String.Format("{0}", selected.GetType).Equals("System.Object[]")  Then  CType(selected, Object()) Else  CType(selected, List(Of Object))

     

    Not the most elegant solution but works pretty well.

    Pablo

    0
  • Ryan Cooney

    Hi Pablo,

    List<Object> is both an IList<Object> and an IEnumerable<Object>.

    Object[] is also both an IList<Object> and an IEnumerable<Object>.

    This means you can cast to either IList<Object> or IEnumerable<Object> and it will work in both Silverlight and HTML5.

    --Ryan

    0
  • Permanently deleted user

    Got it, just tried it and it works on both.

    Thanks!

    0

Please sign in to leave a comment.