This documentation is archived and is not being maintained.
Type.IsMarshalByRefImpl Method
.NET Framework 1.1
Implements the IsMarshalByRef property and determines whether the Type is marshalled by reference.
[Visual Basic] Protected Overridable Function IsMarshalByRefImpl() As Boolean [C#] protected virtual bool IsMarshalByRefImpl(); [C++] protected: virtual bool IsMarshalByRefImpl(); [JScript] protected function IsMarshalByRefImpl() : Boolean;
Return Value
true if the Type is marshalled by reference; otherwise, false.
Remarks
This method can be overridden by a derived class.
Example
[Visual Basic, C#, C++] The following example determines whether the given type is marshalled by reference and displays the result.
[Visual Basic] Imports System Imports System.Reflection Imports Microsoft.VisualBasic Public Class MyTypeDelegatorClass Inherits TypeDelegator Public myElementType As String = Nothing Private myType As Type = Nothing Public Sub New(ByVal myType As Type) MyBase.New(myType) Me.myType = myType End Sub 'New ' Override IsMarshalByRefImpl. Protected Overrides Function IsMarshalByRefImpl() As Boolean ' Determine whether the type is marshalled by reference. If myType.IsMarshalByRef Then myElementType = " marshalled by reference" Return True End If Return False End Function 'IsMarshalByRefImpl End Class 'MyTypeDelegatorClass Public Class MyTypeDemoClass Public Shared Sub Main() Try Dim myType As MyTypeDelegatorClass Console.WriteLine("Determine whether MyContextBoundClass is marshalled by reference.") ' Determine whether MyContextBoundClass is marshalled by reference. myType = New MyTypeDelegatorClass(GetType(MyContextBoundClass)) If myType.IsMarshalByRef Then Console.WriteLine(GetType(MyContextBoundClass).ToString() + " is marshalled by reference.") Else Console.WriteLine(GetType(MyContextBoundClass).ToString() + " is not marshalled by reference.") End If ' Determine whether int is marshalled by reference. myType = New MyTypeDelegatorClass(GetType(Integer)) Console.WriteLine(ControlChars.NewLine + "Determine whether int is marshalled by reference.") If myType.IsMarshalByRef Then Console.WriteLine(GetType(Integer).ToString() + " is marshalled by reference.") Else Console.WriteLine(GetType(Integer).ToString() + " is not marshalled by reference.") End If Catch e As Exception Console.WriteLine("Exception: {0}", e.Message.ToString()) End Try End Sub 'Main End Class 'MyTypeDemoClass ' This class is used to demonstrate 'IsMarshalByRefImpl' method. Public Class MyContextBoundClass Inherits ContextBoundObject Public myString As String = "This class is used to demonstrate members of the Type class." End Class 'MyContextBoundClass [C#] using System; using System.Reflection; public class MyTypeDelegatorClass : TypeDelegator { public string myElementType = null; private Type myType = null ; public MyTypeDelegatorClass(Type myType) : base(myType) { this.myType = myType; } // Override IsMarshalByRefImpl. protected override bool IsMarshalByRefImpl() { // Determine whether the type is marshalled by reference. if(myType.IsMarshalByRef) { myElementType = " marshalled by reference"; return true; } return false; } } public class MyTypeDemoClass { public static void Main() { try { MyTypeDelegatorClass myType; Console.WriteLine ("Determine whether MyContextBoundClass is marshalled by reference."); // Determine whether MyContextBoundClass type is marshalled by reference. myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass)); if( myType.IsMarshalByRef ) { Console.WriteLine(typeof(MyContextBoundClass) + " is marshalled by reference."); } else { Console.WriteLine(typeof(MyContextBoundClass) + " is not marshalled by reference."); } // Determine whether int type is marshalled by reference. myType = new MyTypeDelegatorClass(typeof(int)); Console.WriteLine ("\nDetermine whether int is marshalled by reference."); if( myType.IsMarshalByRef) { Console.WriteLine(typeof(int) + " is marshalled by reference."); } else { Console.WriteLine(typeof(int) + " is not marshalled by reference."); } } catch( Exception e ) { Console.WriteLine("Exception: {0}", e.Message); } } } // This class is used to demonstrate the IsMarshalByRefImpl method. public class MyContextBoundClass : ContextBoundObject { public string myString = "This class is used to demonstrate members of the Type class."; } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; public __gc class MyTypeDelegatorClass : public TypeDelegator { public: String* myElementType; private: Type* myType; public: MyTypeDelegatorClass(Type* myType) : TypeDelegator(myType) { this->myType = myType; } // Override IsMarshalByRefImpl. protected: bool IsMarshalByRefImpl() { // Determine whether the type is marshalled by reference. if (myType->IsMarshalByRef) { myElementType = S" marshalled by reference"; return true; } return false; } }; public __gc class MyTypeDemoClass { }; // This class is used to demonstrate the IsMarshalByRefImpl method. public __gc class MyContextBoundClass : public ContextBoundObject { public: String* myString; }; int main() { try { MyTypeDelegatorClass* myType; Console::WriteLine (S"Determine whether MyContextBoundClass is marshalled by reference."); // Determine whether MyContextBoundClass type is marshalled by reference. myType = new MyTypeDelegatorClass(__typeof(MyContextBoundClass)); if (myType->IsMarshalByRef) { Console::WriteLine(S"{0} is marshalled by reference.", __typeof(MyContextBoundClass)); } else { Console::WriteLine(S"{0} is not marshalled by reference.", __typeof(MyContextBoundClass)); } // Determine whether int type is marshalled by reference. myType = new MyTypeDelegatorClass(__typeof(int)); Console::WriteLine (S"\nDetermine whether int is marshalled by reference."); if (myType->IsMarshalByRef) { Console::WriteLine(S"{0} is marshalled by reference.", __typeof(int)); } else { Console::WriteLine(S"{0} is not marshalled by reference.", __typeof(int)); } } catch (Exception* e) { Console::WriteLine(S"Exception: {0}", e->Message); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
Type Class | Type Members | System Namespace | IsMarshalByRef
Show: