Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ISingletonObjectRegistry.RegisterSingleton Method

Registers the given existing object as singleton in the object registry, under the given object name.

[Visual Basic]
Public Sub RegisterSingleton( _
   ByVal objectName As String, _
   ByVal singletonObject As Object _
void RegisterSingleton(
   string objectName,
   object singletonObject


Name of the object.
The singleton object.


The given instance is supposed to be fully initialized; the registry will not perform any initialization callbacks (in particular, it won't call IInitializingObject's

method). The given instance will not receive any destruction callbacks (like IDisposable's
method) either.

If running within a full IObjectFactory: Register an object definition instead of an existing instance if your object is supposed to receive initialization and/or destruction callbacks.

Typically invoked during registry configuration, but can also be used for runtime registration of singletons. As a consequence, a registry implementation should synchronize singleton access; it will have to do this anyway if it supports a BeanFactory's lazy initialization of singletons.

See Also

ISingletonObjectRegistry Interface | Spring.Objects.Factory.Config Namespace