Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SerializerProvider.CreateSerializerWriter Method

Initializes an object derived from the abstract SerializerWriter class for the specified Stream that will use the specified descriptor.

Namespace: System.Windows.Documents.Serialization
Assembly: PresentationFramework (in presentationframework.dll)

public SerializerWriter CreateSerializerWriter (
	SerializerDescriptor serializerDescriptor,
	Stream stream
)
public SerializerWriter CreateSerializerWriter (
	SerializerDescriptor serializerDescriptor, 
	Stream stream
)
public function CreateSerializerWriter (
	serializerDescriptor : SerializerDescriptor, 
	stream : Stream
) : SerializerWriter
You cannot use methods in XAML.

Parameters

serializerDescriptor

A SerializerDescriptor that contains serialization information for the SerializerWriter.

stream

The Stream to which the returned object writes.

Return Value

An object of a class derived from SerializerWriter.

Exception typeCondition

ArgumentNullException

One of the parameters is null.

ArgumentException

The serializerDescriptor is specifying the wrong version.

-or-

It is not registered.

-or-

The assembly file cannot be found.

-or-

The assembly cannot be loaded.

Only fully trusted applications can call CreateSerializerWriter.

The following example shows using CreateSerializerWriter to return a plug-in serialization writer for saving a file. For the complete sample, see Document Serialization Sample.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft