Article ID: 917841 - Last Review: June 12, 2007 - Revision: 1.2 A reference leak may occur when you pass an XLANG message or an XLANG message part to a method call as a parameter in BizTalk Server 2006On This PageSUMMARYConsider the following scenario. In Microsoft BizTalk Server 2006, you pass an XLANG message or an XLANG message part to a method call as a parameter. In this scenario, a reference leak may occur. This article describes how to avoid a reference leak. MORE INFORMATIONTo avoid a reference leak when you pass an XLANG message or an XLANG message part to a method call as a parameter, use the following methods. Method 1: Pass a message or a message partWhen you pass a message part, do not pass the message part as an XLANGPart argument or return a value of type XLANGPart. This can cause reference leaks that are difficult to resolve. Instead, pass the message part as the type of the part. Consider the following code examples.Code example 1Code example 2Method 2: Pass an XLANGMessage object and an XLANGPart objectDo not use an XLANGMessage object or an XLANGPart object as an orchestration parameter. Instead, use a message type parameter to pass a message. If you want to pass a message part, pass the message. Then, use the part in the function, the subroutine, or the program that is called. If you want only the part value in the function, the subroutine, or the program that is called, use the part type to pass the message.Method 3: Pass a message to user codeTo avoid reference leaks, do not return an XLANGMessage parameter for a method call. If you return an XLANGMessage parameter that is passed in, you cannot call the Dispose method on the parameter inside the method call. If you do this, lifetimes are violated and an exception error occurs.When you pass a message through an XLANGMessage parameter to user code, the message is referenced to the root context. Typically, messages are not referenced to the root context. The lifetime of the root context is the lifetime of the orchestration instance. The root context is used to make sure that the user code does not hold the message after the orchestration instance finishes and closes. If you have to release a message reference in a loop when the message has been passed through an XLANGMessage argument, you can use the XLANGMessage.Dispose method. You can use the XLANGMessage.Dispose method to release the reference to the root context if the following conditions are true:
| Article Translations
|

Back to the top
