Type.IsContextful Property

Gets a value indicating whether the Type can be hosted in a context.

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

'Declaration
Public ReadOnly Property IsContextful As Boolean

Property Value

Type: System.Boolean
true if the Type can be hosted in a context; otherwise, false.

Implements

_Type.IsContextful

A context intercepts calls to the class members and enforces policies that are applied to the class, such as synchronization. For more detailed information on remoting contexts, see Context.

If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false.

The following example demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties of the Type class. It checks whether the given type can be hosted in the context, whether it can be marshaled by reference, and whether the type is a primitive data type.


Imports System
Imports System.Runtime.Remoting.Contexts
Imports Microsoft.VisualBasic
Public Class MyContextBoundClass
    Inherits ContextBoundObject
    Public myString As String = "This class demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties."
End Class 'MyContextBoundClass
Public Class MyTypeDemoClass
    Public Shared Sub Main()
        Try
            ' Determine whether the types can be hosted in a Context.
            Console.WriteLine("The Contextful property for the {0} type is {1}.", GetType(MyTypeDemoClass).Name, GetType(MyTypeDemoClass).IsContextful.ToString())
            Console.WriteLine("The Contextful property for the {0} type is {1}.", GetType(MyContextBoundClass).Name, GetType(MyContextBoundClass).IsContextful.ToString())
            ' Determine whether the types are marshalled by reference.
            Console.WriteLine("The MarshalByRef property of {0} is {1}.", GetType(MyTypeDemoClass).Name, GetType(MyTypeDemoClass).IsMarshalByRef.ToString())
            Console.WriteLine("The MarshalByRef property of {0} is {1}.", GetType(MyContextBoundClass).Name, GetType(MyContextBoundClass).IsMarshalByRef.ToString())
            ' Determine whether the types are primitive datatypes.
            Console.WriteLine("Is {0} a primitive data type? {1}.", GetType(Integer).Name, GetType(Integer).IsPrimitive.ToString())
            Console.WriteLine("Is {0} a primitive data type? {1}.", GetType(String).Name, GetType(String).IsPrimitive.ToString())
        Catch e As Exception
            Console.WriteLine("An exception occurred: " + e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'MyTypeDemoClass


.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft