This documentation is archived and is not being maintained.

Container.GetService Method

Gets the service object of the specified type, if it is available.

[Visual Basic]
Protected Overridable Function GetService( _
   ByVal service As Type _
) As Object
protected virtual object GetService(
 Type service
protected: virtual Object* GetService(
 Type* service
protected function GetService(
   service : Type
) : Object;


The Type of the service to retrieve.

Return Value

An Object implementing the requested service, or a null reference (Nothing in Visual Basic) if the service cannot be resolved.


The default implementation of this method returns a null reference (Nothing in Visual Basic). Implementors can override this method to provide a custom implementation to return a service object. For more information, see IServiceProvider.GetService.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Container Class | Container Members | System.ComponentModel Namespace | System.IServiceProvider