Note: This API is now obsolete.
Registers a single instance that will be returned when an instance of type TService is requested. This instance must be thread-safe when working in a multi-threaded environment. NOTE: Do note that instances supplied by this method NEVER get disposed by the container, since the instance is assumed to outlive this container instance. If disposing is required, use the overload that accepts a FuncTResult delegate.
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 4.6.0
[ObsoleteAttribute("Please use RegisterInstance<TService>(TService) instead. Will be treated as an error from version 5.0. Will be removed in version 6.0.", false)] [EditorBrowsableAttribute(EditorBrowsableState.Never)] public void RegisterSingleton<TService>( TService instance ) where TService : class
<ObsoleteAttribute("Please use RegisterInstance<TService>(TService) instead. Will be treated as an error from version 5.0. Will be removed in version 6.0.", false)> <EditorBrowsableAttribute(EditorBrowsableState.Never)> Public Sub RegisterSingleton(Of TService As Class) ( instance As TService )
The instance to register.
- The interface or base type that can be used to retrieve the instance.
|InvalidOperationException||Thrown when this container instance is locked and can not be altered, or when the TService has already been registered.|
|ArgumentNullException||Thrown when instance is a null reference.|