IDesignerSerializationManager Interface


Provides an interface that can manage design-time serialization.

Namespace:   System.ComponentModel.Design.Serialization
Assembly:  System (in System.dll)

public interface IDesignerSerializationManager : IServiceProvider


Gets a stack-based, user-defined storage area that is useful for communication between serializers.


Indicates custom properties that can be serializable with available serializers.


Adds the specified serialization provider to the serialization manager.

System_CAPS_pubmethodCreateInstance(Type, ICollection, String, Boolean)

Creates an instance of the specified type and adds it to a collection of named instances.


Gets an instance of a created object of the specified name, or null if that object does not exist.


Gets the name of the specified object, or null if the object has no name.

System_CAPS_pubmethodGetSerializer(Type, Type)

Gets a serializer of the requested type for the specified object type.


Gets the service object of the specified type.(Inherited from IServiceProvider.)


Gets a type of the specified name.


Removes a custom serialization provider from the serialization manager.


Reports an error in serialization.

System_CAPS_pubmethodSetName(Object, String)

Sets the name of the specified existing object.


Occurs when GetName cannot locate the specified name in the serialization manager's name table.


Occurs when serialization is complete.

A designer can utilize IDesignerSerializationManager to access services useful to managing design-time serialization processes. For example, a class that implements the designer serialization manager can use this interface to create objects, look up types, identify objects, and customize the serialization of particular types.

The following example illustrates how to use IDesignerSerializationManager to serialize and deserialize Code DOM statements.

using System;
using System.CodeDom;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;

namespace CodeDomSerializerSample
    internal class MyCodeDomSerializer : CodeDomSerializer {
        public override object Deserialize(IDesignerSerializationManager manager, object codeObject) {
            // This is how we associate the component with the serializer.
                CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
                GetSerializer(typeof(MyComponent).BaseType, typeof(CodeDomSerializer));

            /* This is the simplest case, in which the class just calls the base class
                to do the work. */
            return baseClassSerializer.Deserialize(manager, codeObject);

        public override object Serialize(IDesignerSerializationManager manager, object value) {
            /* Associate the component with the serializer in the same manner as with
                Deserialize */
            CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
                GetSerializer(typeof(MyComponent).BaseType, typeof(CodeDomSerializer));

            object codeObject = baseClassSerializer.Serialize(manager, value);

            /* Anything could be in the codeObject.  This sample operates on a
                CodeStatementCollection. */
            if (codeObject is CodeStatementCollection) {
                CodeStatementCollection statements = (CodeStatementCollection)codeObject;

                // The code statement collection is valid, so add a comment.
                string commentText = "This comment was added to this object by a custom serializer.";
                CodeCommentStatement comment = new CodeCommentStatement(commentText);
                statements.Insert(0, comment);
            return codeObject;

    [DesignerSerializer(typeof(MyCodeDomSerializer), typeof(CodeDomSerializer))]
    public class MyComponent : Component {
        private string localProperty = "Component Property Value";
        public string LocalProperty {
            get {
                return localProperty;
            set {
                localProperty = value;


.NET Framework
Available since 1.1
Return to top