Beware of bizarre errors for "unreachable code detected" inside an orchestration - A world apart from the everday ...

A world apart from the everday ...

Assert.IsTrue(Entries.Count == 0);

Beware of bizarre errors for "unreachable code detected" inside an orchestration

If you've done any work with BizTalk orchestrations you've had to construct a message inside an orchestration somewhere ...

There are a couple of ways of achieving this as detailed here by Matt Meleski.

Briefly you can do the following inside an Expression shape or an orchestration

xmlDoc = new System.Xml.XmlDocument();

xmlDoc.LoadXml("<ns0:SomeMessage></ns0:SomeMessage>");

msg_SomeMessage = xmlDoc;

Drop this little bit of magic into a Message Assignment shape and presto, you're ready to go with a blank message of whatever you wish.

No worries there, I've done that a million times if I've done it once, never had any hassles ... until today that is!

I did a similar thing today, except with Xml a little more complex than the trivial example above ... but when attempting to build the orchestration this time I got the following cryptic error message

Cannot implicitly convert type 'System.Xml.XmlDocument' to 'Microsoft.XLANGs.RuntimeTypes.XmlDocumentSerializationProxy'. An explicit conversion exists (are you missing a cast?)

WHAT?

I tried Googl'ing this beauty ... and nudda. Nothing. Oh joy ... now what?

Heck I tried hundreds of different things. Nothing wanted to work. It all looked good to me, but yet for some reason the orchestration just did not want to build.

In my desperate attempt to figure out what was going on I scanned through the build output window, nothing much odd going on in there either except for a small warning hiding away ...

warning X4003: unreachable code detected

Well now ... what have we here?

Seems I had a branch of a decision shape that would never be hit. Well ok, so what? Right?

WRONG!

The problem with this branch was that my Construct message shape was sitting INSIDE this branch. <the reason why this branch was unreachable is worth another post on it's own ...>

No ways ....

I moved the same construct shape to outside of this branch and the orchestration builds fine.

So I fixed the actual cause of the exception, the warning above, by removing the "unreachable" branch of the decision shape; and presto ... my orchestration compiles and all is well once again in my world.

Nice useful exception message there Microsoft, thanks for that!

*sighs*

There goes another hour or three of wasted time; try explain that to your project manager.

Comments

Dale said:

Thanks - your efforts were not wasted - you saved me many hours !

# February 25, 2008 6:04 PM

Richard said:

Thank you.  You saved me many wasted hours.

# May 26, 2009 11:25 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: