So I was answering a question on a internal (to Microsoft) email list I am lucky to be on. Someone asked a question about some code they were having trouble with - the code in question was being called from an Orchestration in BizTalk and they were passing in the message as XmlDocument - converting that to an XmlValidatingReader as a way of validating the document against their schema. I pointed them to my post on using XLANGMessage instead of XmlDocument for performance. This actually seems to have sovled their problem (even though I didn't think it would - I was just sort of morally opposed to creating an XmlDocument and then turning it into an XmlReader when they could just go directly to an XmlReader - why do two steps when one step would work?). Tim Wieman (one of the BizTalk Rangers) pointed out to me that my code didn't explain something really important that my earlier post doesn't mention (perhaps I should edit that post as well now that I am writing this). If you look at the docs for XLANGMessage it is pretty clear that when you are passing XLANGMessage to a .NET component - and you just plan on reading it during your method call - you *should* call Dispose on it before the end of your call. This means you should always put the usage of XLANGMessage inside of a try block and call Dispose in a finally block (as the above documentation link clearly shows). This was my bad - because of course I am generally thinking about .NET and not about COM. Well - BizTalk isn't COM
Read More...