MessageBuffer Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Represents a memory buffer that stores an entire message for future consumption.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
The MessageBuffer type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | BufferSize | Gets the approximate number of bytes accessed by this MessageBuffer. |
![]() | MessageContentType | Gets the type of message content stored in this buffer. |
| Name | Description | |
|---|---|---|
![]() | Close | Finishes working with the buffer. |
![]() | CreateMessage | Returns a copy of the original message. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | WriteMessage | Writes the entire content of this buffer to the specified I/O stream. |
| Name | Description | |
|---|---|---|
![]() ![]() | IDisposable::Dispose | Releases the unmanaged resources used by the MessageBuffer and optionally releases the managed resources. This method cannot be inherited. |
The body of a Message instance can only be accessed or written once. If you wish to access a Message instance more than once, you should use the MessageBuffer class to completely store an entire Message instance into memory.
To retrieve a copy of a Message from the MessageBuffer, you must call the CreateMessage method of the MessageBuffer. This returns an identical copy of the original Message instance you provided.
You can control the maximum size of the buffer by setting BufferSize to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer or properties attached to the message.
You should always close a MessageBuffer instance by calling Close when finished working with it. This ensures the underlying Message (the message passed into the constructor) instance is also closed, which frees system resources.




