Message.CreateBufferedCopy(Int32) Method

Definition

Stores an entire Message into a memory buffer for future access.

C#
public System.ServiceModel.Channels.MessageBuffer CreateBufferedCopy(int maxBufferSize);

Parameters

maxBufferSize
Int32

The maximum size of the buffer to be created.

Returns

A newly created MessageBuffer object.

Exceptions

maxBufferSize is smaller than zero.

The message is closed.

The message has been copied, read or written.

Remarks

The body of a Message instance can only be accessed or written once. If you want to access a Message instance more than once, you should use the MessageBuffer class to completely store an entire Message instance into memory. A MessageBuffer instance is constructed by calling CreateBufferedCopy of a Message instance.

Note

If Version is equal to None, this method only stores the body of the message, not the entire message into the memory buffer.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
UWP 10.0