本文整理匯總了VB.NET中System.Runtime.Remoting.ObjRef類的典型用法代碼示例。如果您正苦於以下問題:VB.NET ObjRef類的具體用法?VB.NET ObjRef怎麽用?VB.NET ObjRef使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ObjRef類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: MyObjRef
' a custom ObjRef class that outputs its status
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Public Class MyObjRef
Inherits ObjRef
' only instantiate using marshaling or deserialization
Private Sub New()
End Sub
Public Sub New(ByVal o As MarshalByRefObject, ByVal t As Type)
MyBase.New(o, t)
Console.WriteLine("Created MyObjRef.")
ORDump()
End Sub
Public Sub New(ByVal i As SerializationInfo, ByVal c As StreamingContext)
MyBase.New(i, c)
Console.WriteLine("Deserialized MyObjRef.")
End Sub
Public Overrides Sub GetObjectData(ByVal s As SerializationInfo, ByVal c As StreamingContext)
' After calling the base method, change the type from ObjRef to MyObjRef
MyBase.GetObjectData(s, c)
s.SetType([GetType]())
Console.WriteLine("Serialized MyObjRef.")
End Sub
Public Overrides Function GetRealObject(ByVal context As StreamingContext) As [Object]
If IsFromThisAppDomain() Or IsFromThisProcess() Then
Console.WriteLine("Returning actual object referenced by MyObjRef.")
Return MyBase.GetRealObject(context)
Else
Console.WriteLine("Returning proxy to remote object.")
Return RemotingServices.Unmarshal(Me)
End If
End Function
Public Sub ORDump()
Console.WriteLine(" --- Reporting MyObjRef Info --- ")
Console.WriteLine("Reference to {0}.", TypeInfo.TypeName)
Console.WriteLine("URI is {0}.", URI)
Console.WriteLine(ControlChars.Cr + "Writing EnvoyInfo: ")
If Not (EnvoyInfo Is Nothing) Then
Dim EISinks As IMessageSink = EnvoyInfo.EnvoySinks
Dim count As Integer = 0
While Not (EISinks Is Nothing)
Console.WriteLine(ControlChars.Tab + "Interated through sink #{0}", (count = count + 1))
EISinks = EISinks.NextSink
End While
Else
Console.WriteLine(ControlChars.Tab + " {no sinks}")
End If
Console.WriteLine(ControlChars.Cr + "Writing ChannelInfo: ")
Dim i As Integer
For i = 0 To ChannelInfo.ChannelData.Length - 1
Console.WriteLine(ControlChars.Tab + "Channel: {0}", ChannelInfo.ChannelData(i))
Next i
Console.WriteLine(" ----------------------------- ")
End Sub
End Class
' a class that uses MyObjRef
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Public Class LocalObject
Inherits MarshalByRefObject
' overriding CreateObjRef will allow us to return a custom ObjRef
Public Overrides Function CreateObjRef(ByVal t As Type) As ObjRef
Return New MyObjRef(Me, t)
End Function
End Class