ServicedComponent.Activate 方法

当从池创建或分配对象时,由基础结构调用。重写此方法以将自定义初始化代码添加到对象中。

**命名空间:**System.EnterpriseServices
**程序集:**System.EnterpriseServices(在 system.enterpriseservices.dll 中)

语法

声明
Protected Friend Overridable Sub Activate
用法

Me.Activate
protected internal virtual void Activate ()
protected public:
virtual void Activate ()
protected void Activate ()
protected internal function Activate ()

示例

下面的代码示例演示如何使用此方法。

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 'Activate
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:
   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() ) );
   }
protected void Activate()
{
    MessageBox.Show(String.Format("Now entering...\nApplication: {0}\n"
        + "Instance: {1}\nContext: {2}\n",
        ContextUtil.get_ApplicationId().ToString(),
        ContextUtil.get_ApplicationInstanceId().ToString(),
        ContextUtil.get_ContextId().ToString()));
} //Activate

.NET Framework 安全性

  • 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见。

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ServicedComponent 类
ServicedComponent 成员
System.EnterpriseServices 命名空间