BizTalk: System.InvalidCastException


I was facing a strange runtime error when calling a BizTalk Orchestration dynamically from another Orchestration. (Dynamic Call Orchestration is not supported out of the box, so we have a custom implementation for that).


System.InvalidCastException: Unable to cast object of type ‘Microsoft.XLANGs.Core.MessageTuple’ to type ‘Microsoft.XLANGs.Core.XMessage’


Apparently, when creating Orchestration message parameters, the VS misinterprets the order of parameters. So we need to verify order and direction (In/Out/Ref) of the parameters inside Orchestration’s auto generated code & designer’s XML

    body (message <Type> Rq, out message <Type> Rs)

We can correct it manually, or delete all code after #endif // __DESIGNER_DATA and reopen Orchestration and modify anything there to regenerate the code.

Posted in BizTalk. 1 Comment »

One Response to “BizTalk: System.InvalidCastException”

  1. diepsh Says:

    Dear Usman Shaheen,

    Thank you so much for your clear information on HSM..I just want to ask you that what if there are 2 ZMK, ZMK and ZMK2 and 1 encrypted ZPK..On such scenario how to get the clear ZPK from ZMK1 and ZMK2.

    Please reply….

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: