Freigeben über


MustRunInClientContextAttribute-Klasse

Erzwingt das Erstellen des attributierten Objekts im Kontext des Erstellers, vorausgesetzt, dies ist möglich. Diese Klasse kann nicht vererbt werden.

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

Syntax

'Declaration
<ComVisibleAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _
Public NotInheritable Class MustRunInClientContextAttribute
    Inherits Attribute
'Usage
Dim instance As MustRunInClientContextAttribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] 
public sealed class MustRunInClientContextAttribute : Attribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets::Class, Inherited=true)] 
public ref class MustRunInClientContextAttribute sealed : public Attribute
/** @attribute ComVisibleAttribute(false) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ 
public final class MustRunInClientContextAttribute extends Attribute
ComVisibleAttribute(false) 
AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) 
public final class MustRunInClientContextAttribute extends Attribute

Hinweise

Wenn ein Konflikt zwischen den Kontextattributen des attributierten Objekts und den Attributen aus dem Kontext des Erstellers auftritt, wird beim Erstellen des Objekts eine System.Runtime.InteropServices.COMException ausgelöst.

Weitere Informationen über das Verwenden von Attributen finden Sie unter Erweitern von Metadaten mithilfe von Attributen.

Beispiel

Im folgenden Codebeispiel wird die Verwendung des MustRunInClientContextAttribute-Typs veranschaulicht.

Imports System
Imports System.EnterpriseServices
Imports System.Reflection


' References:
' System.EnterpriseServices

<MustRunInClientContext()>  _
Public Class MustRunInClientContextAttribute_Ctor
    Inherits ServicedComponent
End Class 'MustRunInClientContextAttribute_Ctor

<MustRunInClientContext(False)>  _
Public Class MustRunInClientContextAttribute_Ctor_Bool
    Inherits ServicedComponent
End Class 'MustRunInClientContextAttribute_Ctor_Bool

<MustRunInClientContext(False)>  _
Public Class MustRunInClientContextAttribute_Value
    Inherits ServicedComponent
    
    Public Sub ValueExample() 
        ' Get the MustRunInClientContextAttribute applied to the class.
        Dim attribute As MustRunInClientContextAttribute = CType(Attribute.GetCustomAttribute(Me.GetType(), GetType(MustRunInClientContextAttribute), False), MustRunInClientContextAttribute)
        
        ' Display the value of the attribute's Value property.
        MsgBox("MustRunInClientContextAttribute.Value: " & attribute.Value)
    
    End Sub 'ValueExample
End Class 'MustRunInClientContextAttribute_Value
using System;
using System.EnterpriseServices;
using System.Reflection;

// References:
// System.EnterpriseServices

[MustRunInClientContext]
public class MustRunInClientContextAttribute_Ctor : ServicedComponent
{
}

[MustRunInClientContext(false)]
public class MustRunInClientContextAttribute_Ctor_Bool : ServicedComponent
{
}

[MustRunInClientContext(false)]
public class MustRunInClientContextAttribute_Value : ServicedComponent
{
    public void ValueExample()
    {
        // Get the MustRunInClientContextAttribute applied to the class.
        MustRunInClientContextAttribute attribute =
            (MustRunInClientContextAttribute)Attribute.GetCustomAttribute(
            this.GetType(),
            typeof(MustRunInClientContextAttribute),
            false);

        // Display the value of the attribute's Value property.
        Console.WriteLine("MustRunInClientContextAttribute.Value: {0}",
            attribute.Value);
    }
}
import System.*;
import System.EnterpriseServices.*;
import System.Reflection.*;
// References:
// System.EnterpriseServices

/** @attribute MustRunInClientContext()
 */
public class MustRunInClientContextAttribute_Ctor extends ServicedComponent
{
} //MustRunInClientContextAttribute_Ctor

/** @attribute MustRunInClientContext(false)
 */
public class MustRunInClientContextAttribute_Ctor_Bool extends ServicedComponent
{
} //MustRunInClientContextAttribute_Ctor_Bool

/** @attribute MustRunInClientContext(false)
 */
public class MustRunInClientContextAttribute_Value extends ServicedComponent
{
    public void ValueExample()
    {
        // Get the MustRunInClientContextAttribute applied to the class.
        MustRunInClientContextAttribute attribute = 
            (MustRunInClientContextAttribute)(Attribute.GetCustomAttribute(
            this.GetType(), MustRunInClientContextAttribute.class.ToType(),
            false));

        // Display the value of the attribute's Value property.
        Console.WriteLine("MustRunInClientContextAttribute.Value: {0}",
            (System.Boolean)attribute.get_Value());
    } //ValueExample
} //MustRunInClientContextAttribute_Value

Vererbungshierarchie

System.Object
   System.Attribute
    System.EnterpriseServices.MustRunInClientContextAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MustRunInClientContextAttribute-Member
System.EnterpriseServices-Namespace