Message.Close Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Closes the Message and releases any resources.
Namespace: System.ServiceModel.Channels
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Syntax
'Declaration
Public Sub Close
public void Close()
Remarks
The Message does have a finalizer, which causes Close to be called for you when the message is garbage-collected. This is non-optimal, as the .NET Framework's Garbage Collection (GC) mechanism does not necessarily run when you run out of system resources other than memory. For this reason, you should always call this method when finished with the contents of the message. The Close method is a synonym for Dispose (which Message also implements). The message also disposes the object that was used to construct the body when it is disposed.
An ObjectDisposedException is thrown if you call any method or access any properties of the message once it is closed. Calling any method or accessing any properties of other objects related to the message once it is closed, (such as message header collection, message property values, or XmlReader instances returned for the body or for a header) has undefined behavior.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.