10. Miscellaneous
10.1 how does. NET remote computing work?
. Net Remote Computing involves sending messages through channels. The two standard channels are HTTP and TCP. Only on the LAN tends to use TCP-HTTP can be used on the LAN and WAN (Internet.
Now supports multiple serialized message formats, such as soap (based on XML) and binary format. By default, the HTTP channel uses soap (serialization soap formatter Of the. NET Runtime Library), and the TCP channel uses binary format (serialization binary formatter Of the. NET Runtime Library ). However, each channel can use any serialized format.
Here are some remote access methods:
Singlecall. Each request from the client is served by a new object. The object is discarded after the request is complete. The ASP + country service can be used in the ASP + environment to save the country of the application or session, so that this model (without country division) becomes nationally supported.
Singleton. All requests on the client are processed by a single server object.
Client-activated object. This is the old (d) com model supported by the country. Here, the client is referenced by a remote object and retains this reference (to keep the remote object alive ), until the access to it is complete.
The distributed garbage collection of objects is managed by a "lease-based life cycle. Each object has a lease time. When this time is reached, the object is disconnected from the remote sub-structure of the. NET Runtime Library. The default Update Time of the object-the lease time is updated when a successful call initiated from the client is made. The client can also display and update the lease time.
10.2 how to obtain the Win32 API in the. NET program?
Use P/invoke. It uses similar technologies as com interoperability, but is used to access static DLL endpoints rather than COM objects. The following is a C # program example that calls the Win32 MessageBox function:
Using system;
Using system. runtime. interopservices;
Class mainapp
{
[Dllimport ("user32.dll", entrypoint = "MessageBox", setlasterror = true, charset = charset. Auto)]
Public static extern int MessageBox (INT hwnd, string strmessage, string strcaption, uint uitype );
Public static void main ()
{
MessageBox (0, "Hello, this is pinvoke in operation! ",". Net ", 0 );
}
}