JustInTimeActivationAttribute Class


Turns just-in-time (JIT) activation on or off. This class cannot be inherited.

public ref class JustInTimeActivationAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
public sealed class JustInTimeActivationAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
type JustInTimeActivationAttribute = class
    inherit Attribute
Public NotInheritable Class JustInTimeActivationAttribute
Inherits Attribute


The following code example demonstrates the use of this attribute.

#using <System.Windows.Forms.dll>
#using <System.Transactions.dll>
#using <System.EnterpriseServices.dll>

using namespace System;
using namespace System::EnterpriseServices;
using namespace System::Windows::Forms;

public ref class ObjectInspector: public ServicedComponent
   String^ IdentifyObject( Object^ obj )
      // Return this object to the pool after use.
      ContextUtil::DeactivateOnReturn = true;

      // Get the supplied object's type.        
      Type^ objType = obj->GetType();

      // Return its name.
      return (objType->FullName);

   virtual void Activate() override
      MessageBox::Show( String::Format( "Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n", ContextUtil::ApplicationId.ToString(), ContextUtil::ApplicationInstanceId.ToString(), ContextUtil::ContextId.ToString() ) );

   virtual void Deactivate() override
      MessageBox::Show( "Bye Bye!" );

   // This object can be pooled.
   virtual bool CanBePooled() override
      return (true);
using System;
using System.EnterpriseServices;
using System.Windows.Forms;

[assembly: ApplicationName("ObjectInspector")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: System.Reflection.AssemblyKeyFile("Inspector.snk")]

[ObjectPooling(MinPoolSize=2, MaxPoolSize=100, CreationTimeout=1000)]
public class ObjectInspector : ServicedComponent

    public string IdentifyObject (Object obj)
        // Return this object to the pool after use.
        ContextUtil.DeactivateOnReturn = true;

        // Get the supplied object's type.
        Type objType = obj.GetType();

        // Return its name.

    protected override void Activate()
        MessageBox.Show( String.Format("Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n",
                                       ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(),
                                       ContextUtil.ContextId.ToString() ) );

    protected override void Deactivate()
        MessageBox.Show("Bye Bye!");

    // This object can be pooled.
    protected override bool CanBePooled()
Imports System.EnterpriseServices
Imports System.Windows.Forms

<Assembly: ApplicationName("ObjectInspector")> 
<Assembly: ApplicationActivation(ActivationOption.Server)> 
<Assembly: System.Reflection.AssemblyKeyFile("Inspector.snk")> 
<JustInTimeActivation(), ObjectPooling(MinPoolSize := 2, MaxPoolSize := 100, CreationTimeout := 1000)>  _
Public Class ObjectInspector
    Inherits ServicedComponent
    Public Function IdentifyObject(ByVal obj As [Object]) As String 
        ' Return this object to the pool after use.
        ContextUtil.DeactivateOnReturn = True
        ' Get the supplied object's type.        
        Dim objType As Type = obj.GetType()
        ' Return its name.
        Return objType.FullName
    End Function 'IdentifyObject

    Protected Overrides Sub Activate() 
        MessageBox.Show(String.Format("Now entering..." + vbLf + "Application: {0}" + vbLf + "Instance: {1}" + vbLf + "Context: {2}" + vbLf, ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(), ContextUtil.ContextId.ToString()))
    End Sub

    Protected Overrides Sub Deactivate() 
        MessageBox.Show("Bye Bye!")
    End Sub

    ' This object can be pooled.
    Protected Overrides Function CanBePooled() As Boolean 
        Return True
    End Function 'CanBePooled

End Class


If JIT activation is specified, then it must not be disabled in the COM+ catalog, and vice versa. If enabled in the COM+ catalog, it must be specified on the component.

JIT activation defaults to off for components which are configured in COM+, but is enabled automatically if automatic transactions are requested.

For more information about using attributes, see Attributes.



Initializes a new instance of the JustInTimeActivationAttribute class. The parameterless constructor enables just-in-time (JIT) activation.


Initializes a new instance of the JustInTimeActivationAttribute class, optionally allowing the disabling of just-in-time (JIT) activation by passing false as the parameter.



When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Gets the value of the JustInTimeActivationAttribute setting.



Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)

Returns the hash code for this instance.

(Inherited from Attribute)

Gets the Type of the current instance.

(Inherited from Object)

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)

Creates a shallow copy of the current Object.

(Inherited from Object)

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)

Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Applies to