It is very easy to build an application that uses the. NET remote processing framework for communication between application domains. You must implement remotable type, service application domain used to listen for requests, and customer application domain. At the same time, you must configure the remoting system for each application domain so that remote activation can be used to activate the remote type.
1. Create a remote type ):
To allow objects in other application domains to use your class instance, your class must be derived from the System. Externalbyrefobject class. The following code describes how to create a remote class:
[Visual Basic]
'Remotabletype. vb
Imports System
Public Class RemotableType
Inherits catalog albyrefobject
Private _ internalString As String = "This is the RemotableType ."
Public Function StringMethod () As String
Return _ internalString
End Function 'stringmethod
End Class 'remotabletype
[C #]
// RemotableType. cs
Using System;
Public class RemotableType: financialbyrefobject {
Private string _ internalString = "This is the RemotableType .";
Public string StringMethod (){
Return _ internalString;
}
}
To use. to compile the class in the above example into a library file, just save it as RemotableType. language-extension (here, language-extension is your language, such as cs and vb ). Run the following command during compilation:
[Visual Basic]
Vbc/t: library RemotableType. vb
[C #]
Csc/noconfig/t: library RemotableType. cs
2. Create a service application ):
To create remote object instances in different application domains, you must create a service application to complete two tasks:
(1) select and register a channel ). This channel is an object that processes the network protocol and serialization format.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.