Export (0) Print
Expand All

JustInTimeActivationAttribute Class

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

Namespace:  System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

[AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)]
[ComVisibleAttribute(false)]
public sealed class JustInTimeActivationAttribute : Attribute

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 Extending Metadata Using Attributes.

The following code example demonstrates the use of this attribute.

using System;
using System.EnterpriseServices;
using 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 : 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. 
        return(objType.FullName);

    }

    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()
    {
        return(true);
    }

}
#using <mscorlib.dll>
#using <System.Windows.Forms.dll>
#using <System.EnterpriseServices.dll>
using namespace System;
using namespace System::EnterpriseServices;
using namespace System::Windows::Forms;

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

[JustInTimeActivation]
[ObjectPooling(MinPoolSize=2, MaxPoolSize=100, CreationTimeout=1000)]
public __gc class ObjectInspector : public 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.
        return(objType->FullName);

    }

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

protected:
    void Deactivate()
    {
        MessageBox::Show(S"Bye Bye!");
    }

    // This object can be pooled.
protected:
    bool CanBePooled()
    {
        return(true);
    }

};

System.Object
  System.Attribute
    System.EnterpriseServices.JustInTimeActivationAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft