This topic has not yet been rated - Rate this topic

ServiceContainer.AddService Method (Type, ServiceCreatorCallback)

Adds the specified service to the service container.

Namespace:  System.ComponentModel.Design
Assembly:  System (in System.dll)
public void AddService(
	Type serviceType,
	ServiceCreatorCallback callback
)

Parameters

serviceType
Type: System.Type

The type of service to add.

callback
Type: System.ComponentModel.Design.ServiceCreatorCallback

A callback object that can create the service. This allows a service to be declared as available, but delays creation of the object until the service is requested.

Implements

IServiceContainer.AddService(Type, ServiceCreatorCallback)
ExceptionCondition
ArgumentNullException

serviceType or callback is null.

ArgumentException

A service of type serviceType already exists in the container.

The following example illustrates how to add a service to a ServiceContainer.

m_MyServiceContainer.AddService(typeof(Control),
                new ServiceCreatorCallback(this.CreateNewControl));

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.