Saturday, April 16, 2005 5:16:44 AM (GMT Daylight Time, UTC+01:00)
Found this great article on IDisposable through Keith's blog. It reminded me of something I've been meaning to post about for a while - that you must never use an object that implements IDisposable from directly from an expression shape in an Orchestration.
In general expression shapes are pretty limited anyway, they aren't actually C# which is a common misconception - they are actually a language called XLANGs. There isn't anyway to step through code you write in an expression. They are really good for the code that is easier to write in an expression than in a C# or VB.NET assembly - like code that reads Context properties or initalizes messages. Anything that isn't BizTalk specific, and anything more complicated than a few lines of code is best done in a C# or VB.NET assembly where you get not only statement completion but also full debugging etc.
But one thing you should never do is use an object that implements IDisposable as a variable in an Orchestration. The above linked article explains the ins and out better than I could of the correct code to use when using an object that implements IDisposable, but writing that code in expression shapes in an Orchestration just isn't possible. There are no finally blocks (exception blocks in a scope shape aren't really implemented as catch blocks away exactly), so there is no place at all to safely call IDisposable.Dispose from. This means directly connecting to a database by using a type like SqlConnection would just lead to potential badness.
BizTalk
Tracked by:
"IDisposable Pattern vs Need for Finalize" (Chanian, Raj) [Trackback]