ServiceContainer.AddService Method (Type, ServiceCreatorCallback)
Adds the specified service to the service container.
Assembly: System (in System.dll)
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)| Exception | Condition |
|---|---|
| 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.
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.