.NET Remoting architecture assessment

xiaoxiao2021-03-05  20

.NET Remoting architecture assessment

Pat MartInmicrosoft Corporation 2003 Suitable for: Microsoft® .NET Framework Microsoft® .NET Remoting Summary: This article applies to those who want to use .NET Remoting for distributed multi-layer applications. Articles introduce the function of this technology from the perspective of developers. Developers have benefited from the convenient RPC mechanism provided by this technology, and they have experienced inconvenience from their shortcomings. This article assumes that readers are familiar with .NET Remoting, even if they are not actually used, at least the concept is also known. Product Features A person who is designed to use Remoting is useful. Best method The section is suitable for the construction of Remoting, Remoting and Web Services Try to eliminate the confusion about "What kind of technology is selected", summary It is refining for the content. table of Contents

Overview Product Features Using Remoting Best Method Remoting and ASP.NET Web Services Summary Other Resources Overview .NET Remoting is known as the preferred technology of RPCs between application domains. The application domain is the isolation unit of the public language runtime, which is created and run in the process. This is different from interprocess communication between the CLR and non-CLR managed processes. The latter type RPC communication (especially on the web) is generally considered to be a problem in the web service area. Unfortunately, this seemingly clear distinction is blurred because it can be embodied in IIS, as described in the text of the Microsoft .NET Remoting Framework:

"You can provide it as a web service as a web service by integrating .NET Remoting objects in IIS ..."

Some Microsoft customers may have some doubts about .NET Remoting. I often hear someone asked "When should I use remoteing?", "When will remote network support NTLM?", "How to ensure the security of remote sessions?", "How does COM ?" And "How to manage transactions" and "Remoting In addition to answering these issues, this article will introduce some best ways to use .NET Remoting, and summarize the current functionality. Abstract The future development direction of this technology is predicted, in particular about Web services and emerging global XML Web Service architectural structures (GXA) specifications. Most of the information section of the product feature is from TECHED N.Z. 2002. This demo focuses on different methods of using Remoting in a distributed solution, which clarifies the advantages of Remoting, which also mentioned some shortcomings. Best Methods For a personal experience of using Remoting in multi-layer .NET applications, it introduces many simple and easy ways to use during development. Some section includes information on the information obtained according to the informal conversation, and the object of the conversation has a deep understanding of the technology and its development direction, but the information provided here will never represent future product release plans or arrangements. Product Features This section describes the features and product features of .NET Remoting. Client / Server Communication .NET Remoting provides a useful way to manage synchronous and asynchronous RPC sessions across application domains. Remote object code can run on the server (such as object activation of the server and client activation), or can run on the client (the remote objects on which it has been serialized through the client / server). In either case, only a small amount of code can only be used in a very simple programming language as long as the initialization and configuration (this is not difficult). The use of the remote object (which is an agent when the agent is generated) is transparent to the programmer. For example, the early Windows RPC mechanism requires familiar types and uses IDL tools to be used to process the developer's public RPC client and server stub management. Remoting is much easier when providing RPC for .NET, and because of the easy-to-understand .NET data type, it eliminates the case where the type mismatch in the early RPC mechanism (this is a very big threat). By default, transing can be configured to use HTTP or TCP protocol and communicate using XML encoded SOAP or native binary messages. Developers can build custom protocols (channels) or message formats (formatted) and are used by the Remoting framework when needed. Both servers and client components can select ports, just like the communication protocol can be selected. One of the advantages of this is that it is easy to establish and run basic communications. However, status management is considered when selecting the communication type. This section will then introduce the various communication options provided by Remoting and its related design meanings. The server activated object "server activation object" is an object that is controlled by the server. They are created by the server as needed only when the client calls the first method of the object. The object activated object only supports the default constructor. To use the parameterized constructor for remote objects, you can use "Client Activation" or "Dynamic Publish" (see below). The object activated by the server is also known as well known object type because its position (URL) is pre-published and known. The object activated object has two activation modes: Singleton and SingleCall, which will be introduced below.

To create an instance of the server activation type, you can configure the application by programming, or a static configuration. The configuration of the server is relatively simple, for example, the following code snippet

Objecturi = "HelloService.soap" />

Describes a service-activated (WellkNown) type, which is activated to set to SingleCall. For more information on confining Remoting, please refer to "Server-Side Registration" in the .NET Framework Developer's Guide on the MSDN. Singleton These objects follow traditional Singleton design patterns in which there is only one instance in memory at any time, and all clients accept the services provided by this instance. However, it is important to note that these types have the default survival associated with it (see the object survival management section below). This means that the client does not have to receive references to this class's reference for classes that can be remotely processed. The latter situation is meaningful to state management, and this Remoting mode is different from the traditional Singleton mode (the same object identification). If your design needs to use traditional Singleton status management mode, there are two ways to resolve this issue. One way is to ignore the default object lease behavior so that "always" is always saved in memory when the host application domain is running. The following code snippet shows how to do this: public class myclass: MarshalByrefObject

{

Public override Object InitializelifetimeService ()

{

Return NULL;

}

}

As mentioned above, this mechanism locks objects into memory and prevents objects from being recycled, but can only do this during the host application. For IIS integration, if the IIS or IIS process of the integrated Remoting session is reclaimed (many reasons can cause this phenomenon), the object will be destroyed. To completely depend on the Remoting thread secure Singleton status data, we need to do three things:

Ignore the rental mechanism so that the rent is indefinite, as described above. Integrating remote servers in our own design, for example, fully controlling system services in its survival. Although this process can also be recovered, its operation is more obvious, more probably compared to the recovery IIS assist process. For more information on this mechanism, see the product feature section below. Develop remote servers as thread secure servers because it can use multiple threads to complete the concurrent request of the client. This means that managing concurrency will write to shared resources and often pay attention to shared access to static memory. SingleCallSinglecAlL Remote Server Types always set an instance for each client. The next method call will be changed by other instances. From a design perspective, the features provided by the SingleCall type are very simple. This mechanism does not provide status management if you need state management, which will be an unfavorable; if you don't need it, this mechanism will be very ideal. Maybe you only care about load balancing and scalability, then in this case, this mode will be your ideal choice because there is only one instance for each request. If you prefer, developers can provide their own status management to the SingleCall object, but this status data will not reside in the object because a new object ID will be instantified each time the new method is called. Dynamic publishing also needs to consider the last type of server activation method, that is, dynamically published. This is a type of server activation, by providing a programmatic publishing mechanism, more control over the object structure can be made. It allows specific objects to be published in a particular URL and you can choose to use the parameterized constructor. From the structure, this type can be seen as a small variation of the server-activated Singleton type. For information on dynamic publishing, see .NET Framework Developer's Guide. Client-activated object "Client Activation Object" is created on the server when the client calls new or activator.createInstance (). The client itself uses the living standard lease system to participate in the living life of these instances. This activation mechanism provides the most widely design flexibility. If you are activated using the client, the activation request will be sent to the server when the client attempts to activate the object. This mechanism allows the use of parameterized constructor and management of connection status for each client. Use client activation, each client accepts its specific server instance provided service, which simplifies a saving process of multiple call timing object status. But be cautious when using these objects, because it is easy to forget the session is distributed, the object is actually not only outside the process, but also in the case of multi-layer applications, it is possible outside the computer (set on the Internet A property is not too much). Practical and non-sprouted interfaces should be the guidelines here: in order to improve performance, we may need to trade between highly combined and loose coupling. To create an instance of the client activation type, you can configure an application by programming, or a static configuration. The configuration is relatively simple on the server on the server, for example, the following code snippet

Objecturi = "HelloService.soap" />

A type of client activation is described. Please note that we no longer need the URL, because the type itself is enough to activate to the type of client. In addition, the WellkNown tag has been replaced by the Activated tag. For more information on configuring Remoting, please refer to the "Server-Side Registration" in the .NET Framework Developer's Guide on the MSDN. Scalability In the process of processing remote method calls, .NET Remoting will format the "message" along Remoting to the server from the client. Message formats and channel itself are fully scalable and customizable. By default channels or formatters can be replaced by a custom-defined component. Messages can be intercepted and changed in multiple "reception points" during transmission, allowing a message to customize the message (eg, message encryption). The Custom Mechanism is described in the .NET Framework Developer's Guide (Sinks and Sink Chains), and some custom channels and formatting programs have appeared on the Internet (for example, the implementation of the NAMED PIPE channel). Most people are not interested in this extension because the default formatting procedures and channels provided by this technology have been used in the widest range (ie TCP and HTTP, especially with SOAP message formatting programs). However, in the initial design phase, you need to consider various solution options, remember that this feature is still necessary. Abnormal propagation .NET Remoting fully supports exception spread across the Remoting boundary, which is the use of error code, such as the major improvement of DCOM. Using Remoting exception, it is best to mark an exception class as sequentially and implements the iSerializable interface. In this way, the exception can be properly serially across the Remoting boundary, or the custom data can be added to an abnormality during the construction process. It is best to define your own anomaly class for an exception to be consistent with remote processing and in use. Make sure to use this method to capture all exceptions and correctly propagate, and unprocessed exceptions are allowed to cross the Remoting boundary. Object Life Management .NET Remoting provides a powerful mechanism for the life of the management remote object. If our server object does not retain any status (such as SingleCall object), you don't have to pay attention to this process, just let the Remoting infrastructure completed the job to be completed, the object will be reclaimed as garbage. If we reserve the status, whether the server activated Singleton or client activation, we may have to participate in the survival management process: object rental. We have seen a small degree of participation, using a simple (and useful) method, is to ignore the Initializer fiFetimeService method, as described above in the introduction of Singleton. This allows us to reserve objects during the process of integrating objects. So, how do this object life work? The object management mechanism provided by Remoting Based on the principle of lease: You will never have an object, just borrow it, you can use it as long as you continue to pay. This process will be further described below. However, first, you must briefly introduce how to handle the object clean in the COM. DCOM integrates two methods using ping and reference counts to determine if the object is still running, which is not only easy to make mistakes, but also high for network bandwidth. When using a reference count, the worst case is never fully understood, and the best situation is also very fragile.

In the past (still still) To apply some simple rules to the reference count to make it work. The iUnknown interface of the COM object includes the AddRef and Release methods, which need to be called when the developer is appropriate. Sometimes the programmer makes it wrong, and the result is that the object is not deleted, and the associated memory leakage. Instead, Remoting is integrated based on rental living-by-life management system, using rental, person in charge, and lease manager. Each application domain contains a lease manager that stores the rental object of each Singleton or client activation in its domain. Each lease can have zero or more relevant person in charge, and the person in charge can re-rent when the lease manager determines the rental expiration. This rental function is provided by the Remoting infrastructure through the ILASE interface, by calling InIstIzelifetimeService, as described above. The ILEASE interface defines a lot of properties used to manage object life: InitialLeaseTime. Determine the initial validity period of rent. Renewoncalltime. Update this time unit rental after each method is called. SponsorshipTimeout. The person in charge not know the time after the rent is expired, Remoting is waiting for time. Currentleasetime. Time (read-only) from the rental expiration. After renting expires, the lease manager will notify all rental person in charge, ask if they want to update the rent. If not updated, the related object reference will be released. The person in charge is an object that can be rented for remote objects. To become the person in charge, your class must be exported from the MarshalByrefObject and implements the ISPonsor interface. A rent can have multiple person in charge, and a person in charge can also participate in multiple rental. For lease management mechanisms for programming using these interfaces, see the .NET Framework Developer's Guide documentation on Lifetime Leases (English), this is not repeated here. However, it is worth noting that this powerful mechanism is just a meaningfulness of the survival of the state-based remote object. As mentioned above, you or completely ignore it, use it to save objects in memory while its process container is run, or is fully involved in the rental mechanism. Remote server integration There are many ways to integrate .NET remote servers, mainly divided into two categories, as described below. The ability of IIS integration under ASP.NET in IIS integrates remote server-side objects is provided as standard features. It has many advantages, including supporting security and scalability. To integrate objects under IIS:

Develop remote classes and inherit from MarshalByrefObject (or declare the class declare). Create a virtual web application using the IIS Manager. Put the assembly that contains your class to the BIN subfolder of the virtual web application. Create a web.config file to save the configuration definition of the Remoting server and place it into the virtual root directory of the web application. It's that simple. However, you should know some restrictions:

You cannot specify an application name for IIS integration because it is a virtual application name. HHTP channels must be used. If the Remoting client is also a web application, you must call RemotingConfiguration.configure when startup, which is usually in the Application_Start method of the global.asax file. You cannot use the tag to automatically configure the client web application. Do not specify ports because IIS will perform port assignment. You can still use IIS management if needed to specify ports for the virtual application. The Remoting application domain will integrate in the ASPNET_WP.EXE assist process, by default, it will use the identity of the process. Note: There is an error in the current ASP.NET, requiring the process identity of the ASPNET_WP.exe auxiliary process to "System" or local computer account, default setting, "Machine" in Machine.Config is incorrect, resulting in domain When the controller's IIS is integrated, an error 500 "Internal Server Error" occurs when the ASP.NET application appears. It can be argued that this error is due to the lack of explanation of how to properly configure the document of the computer account.

There is a lot of features in IIS: By default, it is possible to provide scalability, thread, audit, authentication, authorization, and secure communication. The ASP.NET assist process has been running, and you can use the element in Machine.Config to make threads and error management. In short, IIS's advantages and functions can be used for remote servers. But it also has some shortcomings: you must use HTTP with slow speed than TCP. In addition, IIS may loop the ASP.NET assist process, which will destroy all Singleton's status. For you, this may be a problem or not, depending on your design needs, because the next call of the client will restart Singleton. You can configure IIS to perform an auxiliary process, but this ability is limited, especially in IIS 5, and may result in a further influence. The most fundamentin here is that if the security of the remote server is required, it will undoubtedly use IIS integration. As for performance, only when the problem is actually perceived during system testing / use, and you can always find solutions to problems on hardware. IIS The Authentication Problem Authentication options to consider. Net Remoting No ourselve: Authentication and authorization is performed by channels and host processes, in which case is executed by IIS. Windows authentication can be used for Remoting, configuring the configured in Web.config. You cannot use forms or Passport authentication, because the Remoting client cannot access cookies, or you cannot reallite to the login page (because the remote server is designed for non-interactive use). Passing credentials to remote objects If remote objects are IIS integrated (in the ASP.NET assist process) and configured to use Windows authentication, you must use the channel's credential property to specify the credentials you want to use, otherwise you will lead to any credentials. Remote calls. This negligence is a common reason for HTTP access refusal response. To use the credentials of the process of integrated Remote Object Agents (Remoting Client Process), set the channel's credential property to defaultcredentials maintained by the process credentials. This can be done using channel elements (for web clients), i.e. can also be completed by programming using the following code: idictionary channelding = ChannelServices.getChannelSinkProperties (Proxy);

ChannelProperties ["Credentials"] = CredentialCache.defaultcredentials;

To pass the "specific" credentials along with the remote object call, disable the default credentials, set and use the following code: iDictionary channelProperties =

ChannelServices.getchannenenesinkProperties (Proxy);

NetWorkcredential Credentials;

Credentials = New NetworkCredential ("UserName", "Password", "Domain"); Objref ObjectReference = RemotingServices.Marshal (Proxy);

URI Objecturi = New URI (ObjectReference.uri);

Credentialcache Credcache = New CredentialCache ();

// with Negotiate, Basic, Digest,

// Kerberos or NTLM Replace AuthenticationType

Credcache.Add (Objecturi, "AuthenticationType", Credentials;

ChannelProperties ["CREDENTIALS"] = CREDCACHE;

ChannelProperties ["preauthenticate"] = TRUE;

Note:

The PreAuthenticate property is set to true (as described above) will cause the WWW authentication header to pass with the initial request. This will stop the web server to reject access to the original request, and perform authentication for subsequent requests.

There are many ways to integrate remote integration outside IIS, as shown below. Integrated developers in the console application can write a console application that launches the Remoting infrastructure, and then "stay in the nearby". Leave it in the nearby reason because it contains an application domain integrating remote call. Writing a program is very simple: just call the RemotingConfiguration.configure method, pass your remote host profile to it, and then stop the process by waiting for an event, such as a button or receive a specific message. The advantage of this method is not required to use IIS on the intermediate layer, but it is not possible to generate at any time, so it is suitable for demo, development and testing. This is not to say that it is nothing, but it is limited. Integrated developers in the GUI application can also write a Windows GUI app that launches the Remoting infrastructure, and then "stay in nearby". Similarly, the only reason for continuing execution is that it includes an application domain integrating remote call. Its development method is the same as the console application: the Remoting host can be started directly, or it can be started according to the user's interaction. Similarly, this method also has the advantage of IIS without the intermediate layer and can be used for demos and testing. Do some changes to this program can get peer-to-peer network (logic) WinForms applications, such as applications for chat types. Similarly, the range of use of the program is also very limited. Integrating this possibility in the system service is very interesting, because the function provided by the Remoting infrastructure does not have the function of the system service concept itself. The system service can be configured to start when the computer is started and retained around until you let them leave, which is ideal for remote integration. Note that by setting "high isolation mode" for the virtual application, you can configure the IIS application to have similar behavior. There are still a lot of content worth discussing about this issue. This article does not discuss it. The customer asked many questions about this mechanism, including its use. First, introduce some of its advantages: We have introduced the benefits of the service itself; in addition, we can fully control the activation of the host process, for example, can choose to use dynamic publish or use client activation; do not need IIS, because we can load User profile and you can use binary coding messages on TCP to achieve good performance. But it's a lot of disadvantages. First, you have to build your own authentication and authorization mechanism if needed. .NET Remoting Security Solution, Part 1: Microsoft.samples.security.sspi assembly This article introduces the "security solution for .NET Remoting": "...... implemented SSPI managed packaging, providing verification client And the server and the core function needed to sign and encrypt the message sent between the two. "This is undoubtedly a valuable resource, which provides a mechanism to add this function, which is very useful. But the problem is that it is not a supported product, but a "informal" method for providing supplementary functions. And there is still a threat to developers because the solution depends on formatting programs and channel scalability. All of this requires avoidance, to get functions, you must add an entry to the Remoting Configuration to illustrate using Windows NT Challenge / Response (NTLM). But such security mechanisms are likely to join .NET Remoting's future versions. System services also need to be scalable and can be reused as a Remoting server because these functions will be required because multiple layers of distributed applications will need.

For example, if there is no IIS, integration services will have to manage their audit and authorization, and both of these are IIS attached to standards. For these reasons, the use of system service integration mechanisms is limited, and you have to use in a constrained environment. The news in this environment is queued for separate exchange, and security is not a problem, or you can use IPsec on TCP. . Enterprise Service Management In order to bring remote components to the COM environment (and run in COM context), you need to inherit from ServicesDComponent. Other features provided in ServicedComponent and System.EnterpriseServices Namespaces allow CLR components to specify multiple COM properties, such as representative of transaction requirements and server processes. Plus the strict naming mechanism and use the regsvcs command, the remote component can be part of the entire COM environment. Suppose the remote component needs to inherit from MarshalByrefObject, and the COM component needs to inherit from the servicedcomponent (and there is no multiple inheritance function in .NET managed code), how to achieve this? Fortunately, ServicedComponent is derived from ContextBoundObject, while the latter is derived from the MarshalByrefObject we need. Build a COM integration on Remoting is fully available, and it is indeed possible to obtain an apparent advantage provided by the enterprise service, such as the object pool, distributed transaction support, and role-based security. However, how to do this and such a method does what effect on future verification architecture, or not. We have reason to look forward to, with time, COM context infrastructure and Remoting's context infrastructure will be getting closer. But at this stage, how to do this and when this is not very clear. The best way to use Remoting has always been developed and tested distributed components, but also a headache for developers. The following guidelines are explored in practice, and it is not easy. Getting Started Basic Remoting Task List provides a good start, you can check which tasks to perform when you first set remote, it is best to use this article as a reference for the entire process. Let's take a brief introduction to the steps to perform: Host task design services, select application domain, activation mode, channel, port, and release. Implement the Remoting host application domain (eg IIS / system service). Configure host activation, channels, and protocol settings. It is recommended to use the configuration file to load RemotingConfiguration.configure. Publish Interface for Client Use (see "Interface Publishing Selection" below) below for more information). Client task

Design the client, select the application domain and activation mode. Consider whether you need registration channels and ports. Get remote type metadata. Implement the client application domain. Configure client activation mode and other types of information, such as application name, channel, and object URI, etc. It is recommended to use the configuration file to load RemotingConfiguration.configure. Formatting Selection As standard, Remoting can be configured to use SOAP or binary formatting programs on the HTTP channel, or use binary formatting programs on the TCP channel. In general, this configuration can be implemented in the client configuration file and invoke a static RemotingConfiguration.configure method. For example, to configure the Remoting connection to use the binary formatting program on HTTP, you can complete the configuration entry as follows:

The "Channel REF" here refers to the message format to be sent on the channel, and "formatter Ref" refers to the message format to be sent on the channel. Unfortunately, in the development process, the binary formatter is used for the HTTP channel, which generates the side effects of the blocking server-side error, for example, a general server error or access violation populates to the client. This is because when using a binary format, the client's Remoting component needs to return a message in a binary format. It does not explain the wrong text of plain text and reports the following error:

An exception type in Mscorlib.dll appears system.Runtime.Serialization. SerializationException. SerializationException. Additional information: BinaryFormatter version is not compatible. Requires version 1.0. The received version is 1008738336.1684104552.

This incorrect part is "not" because the version is not compatible, but because the client cannot analyze the wrong response of the text format. Although we believe this protocol defect can be resolved in the future version of the product, but it is also strong that you use the SOAP formatting program during the development process. After confirming, this formatting program can be switched to binary to enhance performance, but should be done in the performance advantage and necessary. After the interface releases the selection and build the Remoting server, the interface to be provided will be published to the client to resolve the reference to compile and allow dynamically to create a proxy object. There are many ways to do this, it is necessary to repeat it. But there are a few prompts first:

Static fields and methods will never perform remote processing, and .NET Remoting always handles some form of instance members. Private method / type cannot be processed remotely. The MARSHALBYREF type is a derived type by reference to remote processing, and the type of sequence is replicated in the client process and executes code. Object virtual methods Equals, GetHashCode and MemberWiseClone, etc. are executed locally. Learn about where these designs should be noted, you can choose to use the following methods to publish interfaces exported by the Remoting server:

Provide the server-side assembly to the client to compile. This method is not necessary when only interfaces are required without implementation. For the SOAP / HTTP client (the function of the Remoting server here is to provide web services, although there are some doubts about this service), the Remoting server can provide a Web Service Description Language (WSDL) file for the server object and method. The SOAPSUDS utility included with the .NET Framework SDK can be used to generate these WSDL files as metadata. In fact, this method is more suitable for web services (from strict ASMX sense) rather than remoting, because the WSDL of the Remoting interface cannot be fully compatible with WSDL of the Web service interface. SOAPSUDS TOOLS Dedicated .NET Framework Tools documentation details the SOAPSUDS utility. Declare an interface in separate libraries and deploy the library using the client. Release the server class that executes the interface, the client will be able to use it, the method is the agent that it is implemented. This is a very clear design choice because it is a particularly interested interface. This approach can only be used for server-activated objects (see Product Features), because unable to create an instance of the interface. Use SOAPSUDS to build an alternate class as a metadata. You can run SOAPSUDS for the Remoting server assembly to generate an output assembly (can be used as metadata) or source files (can be directly included in the application). This mechanism is useful for building multi-layer applications. In this application, the object in the layer is to access the remote object in another layer. This method is interesting, and this method is used in the multi-layer application referenced in the profile section of the above. Suppose we open a command window in the following folders: $ frameworksdk / schessing / technologies / recoting / basic / recotinghello / service

We can write: soapsuds -id: .- types: hello.helloservice, hello -oa: hellointerface.dll This will create an output assembly Hellointerface.dll, which contains only Remoting server based on the current directory. Metadata of Hello.HelloService. The assembly can be used directly by the client. The location of the Remoting server is based on the standard Remoting configuration, which is derived based on the configuration data provided at runtime. MSIL generated for the client assembly

Ldfld Object [system.Runtime.Remoting] system.Runtime.remoting.Services.RemotingClientProxy ::_TP

Clearly show that we did not use the Remoting server implementation, but used a proxy class built by the metadata generated by SOAPSUDS. You cannot ensure that SOAPSUDS is formatted using binary because it embedded / mapped some SOAP unique content in the output program centered data. It is recommended that you try to keep the remote interface, using "enriched" instead of "fancy" interface, that is, try to limit the number of remote calls in the design. In some cases, this may need to pass redundant parameters. Place the remote interface in a separate class, distinguishes with the actual category. This can obtain a surface type mode: When needed, another technology can be easily replaced with the Remoting layer. Management Error This section describes the error conditions that may be encountered during the development (and use) Remoting solution. In any case, you should remember to use and monitor methods to use standards. Event records are still very valuable information resources. Like the Network Monitor tool, the network monitor can specifically view the Remoting session of the client / server. The Remoting server of the intermediate layer can still use the standard debug tool provided by Visual Studio .NET to debug, for example, for Remoting servers integrated by IIS, you can add debugging sessions to the ASP.NET assist process (Debug [debugging " ] | Processes [Process] | Attach [Addition]) to set breakpoints (if resource is available). However, the transing error is very unique and some are listed below. Note that all versions of the Basic Remoting Hello Sample provided by the .NET Framework SDK have been recovered, and the server and clients have also run on a single machine. The fault phenomenon is the same as in the network link, but because the timeout setting of the HTTP / TCP is different, it is necessary to have an error. Lost MarshalByref Since Remoting is used by reference to a given class, this class must only do one thing, that is, inheriting MarshalByrefObject. Suppose developers forget to do this, we will get an exception of system.Runtime.Remoting.Remotingexception type, indicating that we have a "lost MarshalByreference". Whether it can properly capture and handle this RemotInGexception will depend on the programmer. (Think about this developer forgetting the only thing he should remember.) Solution is to remember inheriting MarshalByrefObject! The well-known server-activated error server endpoint is activated for server (see Product Features), and the Remoting server declares its listening to endpoints. This endpoint typically includes an object URI (known as a known name of the remote object), an protocol and a port number. Of course, all of this may configure an error. The wrong URI is provided by the Basic Remoting Hello Sample of the service is HelloService.SoAP, such as specified in the relevant web.config file:

Objecturi = "HelloService.SoAP" />

This service is IIS integration. IIS integration requires the URI with suffix .rem or .soap, we use. Rope on the server. ROPE. In this example, we will receive RemotInGexception again. The text displayed this time is "Object has been disconnected or does not exist" on the server. Make sure that each URI matches each other! When IIS integrates a Remoting server, make sure the URI ends with .rem or .soap. Matching protocols / ports To perform this test, we switch to the console integrated server, the following is the configuration file of the server:

Objecturi = "HelloService.soap" />

Suppose we have to change the protocol to TCP on the server, but keep the client HTTP. We will receive RemotInGexception again, this text is "The underlying connection is closed: unexpected errors when receiving." Port settings errors can also cause the above exception, the only difference in this case, and there is an error in the long time. The ports and protocols between the servers and clients must match. Lost URI Another possibility is that the remote server is not running, for example, the server is integrated by IIS, while the virtual application or related assembly is lost. Using the Basic Hello Remoting server again, we need virtual application Remotinghello to run. If we can't run, we will receive unprocessed exceptions (depending on the calling code), but this exception will be: "Unable to load type CLR: Hello.Hellooservice, Hello". In these cases, make sure the virtual application is running, and the desired assembly is placed in the relevant BIN subfolder. All in all, the client must correctly collect endpoints defined by the server to activate the server, which means that ports, protocols, and URI definitions must match each other. This is too easy to make an error. Therefore, if the location of the server is defined as:

Objecturi = "HelloService.soap" />

Then, the customer's settings must be:

URL = "http://localhost/remotinghello/helloservice.soap" />

Among them, the URL represents an IIS virtual application that integrates Remoting services, the type representation class and assembly name. Remoting and ASP.NET Web Services IT design is also the worst thing is that there are too many architectural components that can be selected. Web services and .NET Remoting are in this case, sometimes it is difficult to determine which technology should be selected for different purposes. Of course, the correct answer is the best technology for the problem to be solved. Do not use "Always use web services" or "Web service is a subset of remoting, so it is equal to all Remoting" and other instructions. This section will mainly introduce these two technologies, indicating why it is to choose this more meaningful rather than another. ASP.NET Web Services and .NET Remoting let us start from the definition of the web service, defined that the web service is available on the Web. This definition is not very useful, and we may take it to refine it into a "addressable processing unit through SOAP and HTTP, this processing unit is described in WSDL, which can be released through UDDI." This definition is much more Because it is separated by the web service and the web server to send HTML back to the browser. In order to compare with .NET Remoting, we especially emphasize the definition of the web service, which is different from the programming services that can be provided on the Web. For example, according to our definition, you can use the remote host accessible from the client from the client through HTTP. In view of this (and emphasizing Microsoft ASP.NET Web Service implementation), what factors should be considered when selecting ASP.NET Web Services and .NET Remoting's "combination"? Interoperability A common Microsoft Theory is: If you need to interoperate between different systems, you should choose a web service method using Open Standards (SOAP, XML, HTTP), and use .NET Remoting by no interaction Solution; if all components in various systems are CLR hosted, .NET Remoting "Possible" is the correct choice. This principle has a wide range of applications, but it is still very useful. The client of the .NET remote object should be the .NET client. If your feature must be implemented on the web (web, the Internet), the web service will be the correct choice. Of course, intranet is not subject to this restriction: all clients can be .NET clients, and do not exclude .NET Remoting in this configuration. Similarly, for the intermediate layer of the application in the firewall and directly communicate with the web layer, you can still select .NET Remoting. Powerful Types support .NET Remoting supports all managed types, classes, interfaces, enumerations, objects, etc., which are often referred to as "multiple types of fidelity". The key here is that if the client and server components are objects that are running in the application domain, the interoperability of the data type is not problematic. Fundamentally, we have a closed system, and both ends of the session can be fully understood, so we can make full use of this fact, handle data types and objects for communication. In the case where various systems coexist, we need to consider interoperability between systems. We must be careful for interoperable data types. For example, the definition of the web service data type is based on the description of the data type based on the XML schema definition (XSD).

Any types that can be described using XSD and can be used on SOAP. However, this is indeed enabled some data types that cannot be used. For example, for unsigned characters or enumerations, there is no corresponding W3C XSD representation. For different web services, the processing of the collection, the processing of exceptions and data sets is also different. Another problem is that private fields and attributes are not passed between web service calls, which is not a key issue for fields and attributes itself, but if your system requires interoperability between different technologies, it is designed and This is a factor to consider when testing the system, because it can be sent to receive it. Repeat again, if interoperability is required between different systems, you should not consider using .NET Remoting technology. If it is a closed, CLR hosted solution, you can use it. Status Management We have seen many ways to implement status management using .NET Remoting based on activation (client activation or singleton). For .NET Remoting and Web services, manage each client's connection status by http (with unstertable timeless stateless state) is a cumbersome and unrealistic thing. However, if you need to maintain a state, Remoting provides a solution based on each object. The Web service does not provide this connection status management of each client, but provides access to the ASP.NET session and application objects. Law management and status management are related to survival management. As we have seen, transoting provides a powerful mechanism for managing the life of the remote object. Web service objects exist and disappear with the call of Web services (from conceptual speaking, both synchronization and asynchronous). In this regard, the Web Services is a single call type compared to Remoting. Remoting provides a greater level of control over the activation and termination of the remote object. This may be meaningful for your design or meaningless. Press value calls and calls to the web service call by reference calls are serialized and transmitted by values. Objects passing to remoting or called object itself can be passed by value or by reference. The serialized remote object method is to process on the client. These differences should be considered when you choose between Remoting and Web services. Of course, these considerations are important to you, but also depends on the nature of the problem to be solved. Supported protocol Web service calls is limited to the XML of SOAP encoded on HTTP. Remoting can use TCP to transfer, or extend infrastructure to support custom protocols. For example, the Jhawk User Sample section on www.gotdotnet.com provides a Remoting implementation using Named Pipe. Here is a fragment of NamedPipe readme file, which clarifies the scalability of Remoting: By implementing an IChannel * interface, you can use the pluggable channel structure to insert the channel into .NET Remoting.

Named PIPE channel supports the following features:

* Communication via naming pipeline

* Synchronous message

* Asynchronous message

* One way message

* Callback

* Channel reception

* Channel properties

* Automatically generate pipe names

Therefore, if you need NAMED PIPE, Remoting can provide a solution. However, like SSPI NTLM authentication solutions, Microsoft does not support this solution, perhaps future Microsoft will meet this needs. Performance If performance is really important to your design, Remoting, which is used in TCP, does provide some significant performance advantages. For the results described herein, if you want to completely understand the test environment and tests that generate this result, see Performance Comparison: .NET Remoting with ASP.NET Web Services. Here is some of the performance statistics summed up from this article: Legend: ASMX - Web Services, others are Remoting Solutions

WS represents a Windows service that integrates remote components.

Figure 1: Performance statistics Next, the performance chart is explained, as described below:

"As shown above, for WS_TCP_BINARY, the object is configured to use TCP channels and binary formatting programs, and the host is Windows service, which is better than other distributed technology. This is because the method passes the original TCP The word transmission binary data (high efficiency than HTTP), and the data does not require encoding / decoding, thereby reducing system overhead. It can be seen that there is about 60% of the performance gap between WS_TCP_BINARY and the slowest method.

Although IIS_HTTP_BINARY is the same as the binary load generated by WS_HTTP_BINARY, it has a slower speed because there is an additional process hop from IIS (inetinfo.exe) to ASPNET_WP.EXE. The performance difference between IIS_HTTP_SOAP and WS_HTTP_SOAP is also caused.

The performance of WS_HTTP_BINARY and WS_TCP_SOAP is almost the same. Although the former has an additional system overhead of HTTP analysis, the latter has additional system overhead in SOAP analysis, but in this example, the system overhead of HTTP analysis is almost the same as the SOAP analysis system overhead.

The performance of the ASP.NET Web service is better than IIS_HTTP_SOAP and WS_HTTP_SOAP because the ASP.NET XML serialization is higher than the .NET Remoting SOAP serialization. As can be seen from the above, the performance of the ASP.NET Web service is almost the same. "

If the original speed is really very important, then this "60% performance gap" is very meaningful. The disadvantage is to integrate the server in a Windows service to use the TCP protocol (see the previous remote integration section). It effectively weighs performance security and is a method that best not used for Internet or unsafe intranet. Small junction ASP.NET Web services Based on XML, it is used to request a simple programming mode and powerful cross-platform support using HTTP (assuming their integration in IIS). It provides a certain degree of scalability by using SOAPEXTensions. For example, an encrypted data stream. Remoting's programming mode is more complicated, but in terms of protocol and message format, it has a significant advantage in terms of type fidelity, state management, and scalability. Remoting cannot be used for non-.NET clients, so the Internet client cannot be implemented directly to the remote host. Remoting cannot provide a security model when integrated outside IIS. When integrated in IIS, Remoting provides the same security features as ASP.NET, including security protocols such as SSL. If you don't need to consider interoperability with other platforms, and the client and server configuration is completely under your control, you can consider using .NET Remoting. Using Remoting, IIS integration using HTTP channels is better than non IIS integration so that it can benefit from the relevant security and scalability infrastructure. Of course, this means you have to interoperate with IIS in the solution. If this is unable to implement, then transnet "possibilities" is the difficult task that is unable to implement, which is related to the nature of the problem to be solved. Since .NET Remoting requires the use .NET client, it is necessary to use the fastest available formatting program, so that binary is selected without choosing SOAP will produce better performance. Remember the recommended recommendations of the best method of the above, use this formatting program while publishing, instead of using it during development. Abstract .NET Remoting is a valid tool used in certain distributed solutions that provides scalable models in supported protocols and message formats, and can provide performance advantages in specific situations. It should not be deployed directly on the Internet, and its server objects should be integrated under IIS to take advantage of the security and performance characteristics provided by IIS as the process running under its control. For "closed" distributed solutions, the clients and servers are CLR hosting processes, and should consider using Remoting. For example, an Intranet solution uses a security TCP channel (such as IPSec) or any layer of any layer of HTTP, or through the firewall and an intermediate application component of the .NET Web layer component session. In this case, after confirming the application using the SOAP formatting program, you should select the binary formatter and HTTP channels. For systems to interoperate with non-CLR clients, use the ASMX web service, but should be carefully handled (see powerful type support). Please note that using TCP integration outside IIS will bring performance advantages, but you need to customize security. Design and implementation of implementation and configuration Remoting is a fairly easy process. In this process, first select the Remoting host, protocol, and activation mode. Please try to simplify the design and implementation process and carefully consider which interface publishing mechanism is the most meaningful for your solution. The recommended method is to release the interface as the most readily understood model, but this cannot be used to activate the object.

Debugging procedures, event logs, and network monitoring are a very useful tool during the development process. When developing remote components, they can also help you. Remoting's future like "When to use Remoting, when to use Web services" is difficult to answer, not to mention the definition of terms is not very clear. For example, if the definition of the web service is unclear, Remoting is likely to be configured as a Web service. Perhaps Remoting and ASMX technology will gradually fuse. But at present, we can at least reasonably explain to where to use which technique is used, as described above. Current development focuses on providing GXA implementations for routing, security, and transaction support. This implementation is based on the use of the SOAP header, and the current direct goal is to extend the functionality of the web service. Although as described herein, from the traditional sense, GXA does not support .NET Remoting, but it supports many problems such as status and transaction management. Although the current GXA implementation can solve many of the problems faced by the Web service, its most fundamental purpose is to solve these problems in a way that does not require too high technical content. Seeing the impact of GXA's development on Web services and .NET Remoting, it will be a fun thing. Other Resources Accessing Objects in Other Application Domains using .NET Remoting (English) Microsoft PAG Building Secure ASP.NET Applications, Chapter 11: Remoting Security (English) Enterprise: Remoting reading list (English) ASP.NET Web Services or .NET Remoting: how to choose

Suitable for: Microsoft® .NET Framework Microsoft® .NET Remoting

Summary: This article applies to those who want to distribute .NET Remoting to distributed multi-layer applications. Articles introduce the function of this technology from the perspective of developers. Developers have benefited from the convenient RPC mechanism provided by this technology, and they have experienced inconvenience from their shortcomings. This article assumes that readers are familiar with .NET Remoting, even if they are not actually used, at least the concept is also known.

Product Features A person who is designed to use Remoting is useful. Best method The section is suitable for the construction of Remoting, Remoting and Web Services Try to eliminate the confusion about "What kind of technology is selected", summary It is refining for the content.

table of Contents

Overview Product Features Using Remoting Best Method Remoting and ASP.NET Web Services Summary Other Resources

Overview

.NET Remoting is known as the preferred technology for the RPC between the management application domain. The application domain is the isolation unit of the public language runtime, which is created and run in the process. This is different from interprocess communication between the CLR and non-CLR managed processes. The latter type RPC communication (especially on the web) is generally considered to be a problem in the web service area. Unfortunately, this seemingly clear distinction is blurred because it can be embodied in IIS, as described in the text of the Microsoft .NET Remoting Framework:

"You can provide it as a web service as a web service by integrating .NET Remoting objects in IIS ..."

Some Microsoft customers may have some doubts about .NET Remoting. I often hear someone asked "When should I use remoteing?", "When will remote network support NTLM?", "How to ensure the security of remote sessions?", "How does COM ?" And "How to manage transactions" and "Remoting In addition to answering these issues, this article will introduce some best ways to use .NET Remoting, and summarize the current functionality. Abstract The future development direction of this technology is predicted, in particular about Web services and emerging global XML Web Service architectural structures (GXA) specifications.

Most of the information section of the product feature is from TECHED N.Z. 2002. This demo focuses on different methods of using Remoting in a distributed solution, which clarifies the advantages of Remoting, which also mentioned some shortcomings.

Best Methods For a personal experience of using Remoting in multi-layer .NET applications, it introduces many simple and easy ways to use during development.

Some section includes information on the information obtained according to the informal conversation, and the object of the conversation has a deep understanding of the technology and its development direction, but the information provided here will never represent future product release plans or arrangements.

Product Features

This section describes the function and product characteristics of .NET Remoting.

Client / Server Communication

.NET Remoting provides a useful way to manage synchronous and asynchronous RPC sessions across application domains. Remote object code can run on the server (such as object activation of the server and client activation), or can run on the client (the remote objects on which it has been serialized through the client / server). In either case, only a small amount of code can only be used in a very simple programming language as long as the initialization and configuration (this is not difficult). The use of the remote object (which is an agent when the agent is generated) is transparent to the programmer. For example, the early Windows RPC mechanism requires familiar types and uses IDL tools to be used to process the developer's public RPC client and server stub management. Remoting is much easier when providing RPC for .NET, and because of the easy-to-understand .NET data type, it eliminates the case where the type mismatch in the early RPC mechanism (this is a very big threat).

By default, transing can be configured to use HTTP or TCP protocol and communicate using XML encoded SOAP or native binary messages. Developers can build custom protocols (channels) or message formats (formatted) and are used by the Remoting framework when needed. Both servers and client components can select ports, just like the communication protocol can be selected. One of the advantages of this is that it is easy to establish and run basic communications.

However, status management is considered when selecting the communication type. This section will then introduce the various communication options provided by Remoting and its related design meanings.

Sense of server activation

"The server activation object" is an object that is controlled by the server. They are created by the server as needed only when the client calls the first method of the object. The object activated object only supports the default constructor. To use the parameterized constructor for remote objects, you can use "Client Activation" or "Dynamic Publish" (see below). The object activated by the server is also known as well known object type because its position (URL) is pre-published and known. The object activated object has two activation modes: Singleton and SingleCall, which will be introduced below. To create an instance of the server activation type, you can configure the application by programming, or a static configuration. The configuration of the server activation is quite simple, for example, the following code snippet

Objecturi = "HelloService.soap" />

Describes a service-activated (WellkNown) type, which is activated to set to SingleCall. For more information on confining Remoting, please refer to "Server-Side Registration" in the .NET Framework Developer's Guide on the MSDN.

Singleton

These objects follow traditional Singleton design patterns in which there is only one instance in memory at any time, and all clients accept the services provided by this instance. However, it is important to note that these types have the default survival associated with it (see the object survival management section below). This means that the client does not have to receive references to this class's reference for classes that can be remotely processed. The latter situation is meaningful to state management, and this Remoting mode is different from the traditional Singleton mode (the same object identification). If your design needs to use traditional Singleton status management mode, there are two ways to resolve this issue. One way is to ignore the default object lease behavior so that "always" is always saved in memory when the host application domain is running. The following code snippet shows how to do this:

Public class myclass: MarshalByrefObject

{

Public override Object InitializelifetimeService ()

{

Return NULL;

}

}

As mentioned above, this mechanism locks objects into memory and prevents objects from being recycled, but can only do this during the host application. For IIS integration, if the IIS or IIS process of the integrated Remoting session is reclaimed (many reasons can cause this phenomenon), the object will be destroyed.

To completely depend on the Remoting thread secure Singleton status data, we need to do three things:

Ignore the rental mechanism so that the rent is indefinite, as described above. Integrating remote servers in our own design, for example, fully controlling system services in its survival. Although this process can also be recovered, its operation is more obvious, more probably compared to the recovery IIS assist process. For more information on this mechanism, see the product feature section below. Develop remote servers as thread secure servers because it can use multiple threads to complete the concurrent request of the client. This means that managing concurrency will write to shared resources and often pay attention to shared access to static memory.

SingleCall

SingleCall Remote Server Type always sets an instance for each client request. The next method call will be changed by other instances. From a design perspective, the features provided by the SingleCall type are very simple. This mechanism does not provide status management if you need state management, which will be an unfavorable; if you don't need it, this mechanism will be very ideal. Maybe you only care about load balancing and scalability, then in this case, this mode will be your ideal choice because there is only one instance for each request. If you prefer, developers can provide their own status management to the SingleCall object, but this status data will not reside in the object because a new object ID will be instantified each time the new method is called. Dynamically released

It is also necessary to consider the last type of server activation method, that is, dynamically published. This is a type of server activation, by providing a programmatic publishing mechanism, more control over the object structure can be made. It allows specific objects to be published in a particular URL and you can choose to use the parameterized constructor. From the structure, this type can be seen as a small variation of the server-activated Singleton type. For information on dynamic publishing, see .NET Framework Developer's Guide.

Client activation object

"Client Activation Object" is created on the server when the client calls new or activator.createInstance (). The client itself uses the living standard lease system to participate in the living life of these instances. This activation mechanism provides the most widely design flexibility. If you are activated using the client, the activation request will be sent to the server when the client attempts to activate the object. This mechanism allows the use of parameterized constructor and management of connection status for each client. Use client activation, each client accepts its specific server instance provided service, which simplifies a saving process of multiple call timing object status. But be cautious when using these objects, because it is easy to forget the session is distributed, the object is actually not only outside the process, but also in the case of multi-layer applications, it is possible outside the computer (set on the Internet A property is not too much). Practical and non-sprouted interfaces should be the guidelines here: in order to improve performance, we may need to trade between highly combined and loose coupling. To create an instance of the client activation type, you can configure an application by programming, or a static configuration. The configuration of the client activation is relatively simple on the server, for example, the following code snippet

Objecturi = "HelloService.soap" />

A type of client activation is described. Please note that we no longer need the URL, because the type itself is enough to activate to the type of client. In addition, the WellkNown tag has been replaced by the Activated tag. For more information on configuring Remoting, please refer to the "Server-Side Registration" in the .NET Framework Developer's Guide on the MSDN.

Extensibility

During processing remote method calls, .NET Remoting will format the "message" along Remoting to the server from the client. Message formats and channel itself are fully scalable and customizable. By default channels or formatters can be replaced by a custom-defined component. Messages can be intercepted and changed in multiple "reception points" during transmission, allowing a message to customize the message (eg, message encryption). The Custom Mechanism is described in the .NET Framework Developer's Guide (Sinks and Sink Chains), and some custom channels and formatting programs have appeared on the Internet (for example, the implementation of the NAMED PIPE channel). Most people are not interested in this extension because the default formatting procedures and channels provided by this technology have been used in the widest range (ie TCP and HTTP, especially with SOAP message formatting programs). However, in the initial design phase, you need to consider various solution options, remember that this feature is still necessary. Abnormal transmission

.NET Remoting fully supports exception spread across the Remoting boundary, which is a major improvement to use error code, such as DCOM.

Using Remoting exception, it is best to mark an exception class as sequentially and implements the iSerializable interface. In this way, the exception can be properly serially across the Remoting boundary, or the custom data can be added to an abnormality during the construction process. It is best to define your own anomaly class for an exception to be consistent with remote processing and in use. Make sure to use this method to capture all exceptions and correctly propagate, and unprocessed exceptions are allowed to cross the Remoting boundary.

Object life management

.NET Remoting provides a powerful mechanism for the survival of the management of the remote object. If our server object does not retain any status (such as SingleCall object), you don't have to pay attention to this process, just let the Remoting infrastructure completed the job to be completed, the object will be reclaimed as garbage. If we reserve the status, whether the server activated Singleton or client activation, we may have to participate in the survival management process: object rental. We have seen a small degree of participation, using a simple (and useful) method, is to ignore the Initializer fiFetimeService method, as described above in the introduction of Singleton. This allows us to reserve objects during the process of integrating objects. So, how do this object life work?

The object management mechanism provided by Remoting Based on the principle of lease: You will never have an object, just borrow it, you can use it as long as you continue to pay. This process will be further described below. However, first, you must briefly introduce how to handle the object clean in the COM. DCOM integrates two methods using ping and reference counts to determine if the object is still running, which is not only easy to make mistakes, but also high for network bandwidth. When using a reference count, the worst case is never fully understood, and the best situation is also very fragile. In the past (still still) To apply some simple rules to the reference count to make it work. The iUnknown interface of the COM object includes the AddRef and Release methods, which need to be called when the developer is appropriate. Sometimes the programmer makes it wrong, and the result is that the object is not deleted, and the associated memory leakage.

Instead, Remoting is integrated based on rental living-by-life management system, using rental, person in charge, and lease manager. Each application domain contains a lease manager that stores the rental object of each Singleton or client activation in its domain. Each lease can have zero or more relevant person in charge, and the person in charge can re-rent when the lease manager determines the rental expiration. This rental function is provided by the Remoting infrastructure through the ILASE interface, by calling InIstIzelifetimeService, as described above. The ILEASE interface defines a lot of properties used to manage object life: InitialLeaseTime. Determine the initial validity period of rent. Renewoncalltime. Update this time unit rental after each method is called. SponsorshipTimeout. The person in charge not know the time after the rent is expired, Remoting is waiting for time. Currentleasetime. Time (read-only) from the rental expiration.

After renting expires, the lease manager will notify all rental person in charge, ask if they want to update the rent. If not updated, the related object reference will be released.

The person in charge is an object that can be rented for remote objects. To become the person in charge, your class must be exported from the MarshalByrefObject and implements the ISPonsor interface. A rent can have multiple person in charge, and a person in charge can also participate in multiple rental.

For lease management mechanisms for programming using these interfaces, see the .NET Framework Developer's Guide documentation on Lifetime Leases (English), this is not repeated here. However, it is worth noting that this powerful mechanism is just a meaningfulness of the survival of the state-based remote object. As mentioned above, you or completely ignore it, use it to save objects in memory while its process container is run, or is fully involved in the rental mechanism.

Remote server integration

There are many ways to integrate .NET remote servers, mainly divided into two categories, as described below.

IIS integration under ASP.NET

The ability to integrate remote server-side objects in IIS is provided as standard features. It has many advantages, including supporting security and scalability.

To integrate objects under IIS:

Develop remote classes and inherit from MarshalByrefObject (or declare the class declare). Create a virtual web application using the IIS Manager. Put the assembly that contains your class to the BIN subfolder of the virtual web application. Create a web.config file to save the configuration definition of the Remoting server and place it into the virtual root directory of the web application.

It's that simple. However, you should know some restrictions:

You cannot specify an application name for IIS integration because it is a virtual application name. HHTP channels must be used. If the Remoting client is also a web application, you must call RemotingConfiguration.configure when startup, which is usually in the Application_Start method of the global.asax file. You cannot use the tag to automatically configure the client web application. Do not specify ports because IIS will perform port assignment. You can still use IIS management if needed to specify ports for the virtual application.

The Remoting application domain will integrate in the ASPNET_WP.EXE assist process, by default, it will use the identity of the process.

Note: There is an error in the current ASP.NET, requiring the process identity of the ASPNET_WP.exe auxiliary process to "System" or local computer account, default setting, "Machine" in Machine.Config is incorrect, resulting in domain When the controller's IIS is integrated, an error 500 "Internal Server Error" occurs when the ASP.NET application appears. It can be argued that this error is due to the lack of explanation of how to properly configure the document of the computer account. There is a lot of features in IIS: By default, it is possible to provide scalability, thread, audit, authentication, authorization, and secure communication. The ASP.NET assist process has been running, and you can use the element in Machine.Config to make threads and error management. In short, IIS's advantages and functions can be used for remote servers.

But it also has some shortcomings: you must use HTTP with slow speed than TCP. In addition, IIS may loop the ASP.NET assist process, which will destroy all Singleton's status. For you, this may be a problem or not, depending on your design needs, because the next call of the client will restart Singleton. You can configure IIS to perform an auxiliary process, but this ability is limited, especially in IIS 5, and may result in a further influence. The most fundamentin here is that if the security of the remote server is required, it will undoubtedly use IIS integration. As for performance, only when the problem is actually perceived during system testing / use, and you can always find solutions to problems on hardware.

Authentication problem to consider under IIS

Authentication option

.NET Remoting has no own security mode: authentication and authorization is performed by channels and host processes, and in this case it is executed by IIS. Windows authentication can be used for Remoting, configuring the configured in Web.config. You cannot use forms or Passport authentication, because the Remoting client cannot access cookies, or you cannot reallite to the login page (because the remote server is designed for non-interactive use).

Pass credentials to remote objects

If the remote object is IIS integration (in the ASP.NET assist process) and configured to use Windows authentication, you must use the channel's credential property to specify the credentials you want to use, otherwise it will result in remote calls without passing any credentials. This negligence is a common reason for HTTP access refusal response. To use the credentials of the process of integrated Remote Object Agents (Remoting Client Process), set the channel's credential property to defaultcredentials maintained by the process credentials. This can be done using channel elements (for web clients), i.e. can also be done using the following code:

IDictionary channelproperties;

ChannelProperties = ChannelServices.getchannenelSinkProperties (Proxy);

ChannelProperties ["Credentials"] = CredentialCache.defaultcredentials;

To pass the "specific" credentials along with the remote object call, disable the default credentials, set and use the following code: iDictionary channelProperties =

ChannelServices.getchannenenesinkProperties (Proxy);

NetWorkcredential Credentials;

Credentials = New NetworkCredential ("UserName", "Password", "Domain");

Objref ObjectReference = RemotingServices.Marshal (Proxy);

URI Objecturi = New URI (ObjectReference.uri);

Credentialcache Credcache = New CredentialCache ();

// with Negotiate, Basic, Digest,

// Kerberos or NTLM Replace AuthenticationType

Credcache.Add (Objecturi, "AuthenticationType", Credentials;

ChannelProperties ["CREDENTIALS"] = CREDCACHE;

ChannelProperties ["preauthenticate"] = TRUE;

Note:

The PreAuthenticate property is set to true (as described above) will cause the WWW authentication header to pass with the initial request. This will stop the web server to reject access to the original request, and perform authentication for subsequent requests.

Integrated outside IIS

There are many ways to remotely integrate outside IIS, as shown below.

Integrate in the console application

Developers can write a console application that launches the Remoting infrastructure, and then "stay in nearby". Leave it in the nearby reason because it contains an application domain integrating remote call. Writing a program is very simple: just call the RemotingConfiguration.configure method, pass your remote host profile to it, and then stop the process by waiting for an event, such as a button or receive a specific message.

The advantage of this method is not required to use IIS on the intermediate layer, but it is not possible to generate at any time, so it is suitable for demo, development and testing. This is not to say that it is nothing, but it is limited.

Integrate in the GUI application

Developers can also write a Windows GUI application that launches the Remoting infrastructure and "stay in nearby". Similarly, the only reason for continuing execution is that it includes an application domain integrating remote call. Its development method is the same as the console application: the Remoting host can be started directly, or it can be started according to the user's interaction. Similarly, this method also has the advantage of IIS without the intermediate layer and can be used for demos and testing. Do some changes to this program can get peer-to-peer network (logic) WinForms applications, such as applications for chat types. Similarly, the range of use of the program is also very limited.

Integrate in system services

This possibility is very interesting, because the function provided by the Remoting infrastructure does not have the function of the system service concept itself. The system service can be configured to start when the computer is started and retained around until you let them leave, which is ideal for remote integration. Note that by setting "high isolation mode" for the virtual application, you can configure the IIS application to have similar behavior. There are still a lot of content worth discussing about this issue. This article does not discuss it. The customer asked many questions about this mechanism, including its use. First, introduce some of its advantages: We have introduced the benefits of the service itself; in addition, we can fully control the activation of the host process, for example, can choose to use dynamic publish or use client activation; do not need IIS, because we can load User profile and you can use binary coding messages on TCP to achieve good performance. But it's a lot of disadvantages. First, you have to build your own authentication and authorization mechanism if needed. .NET Remoting Security Solution, Part 1: Microsoft.samples.security.sspi assembly This article introduces the "security solution for .NET Remoting": "...... implemented SSPI managed packaging, providing verification client And the server and the core function needed to sign and encrypt the message sent between the two. "This is undoubtedly a valuable resource, which provides a mechanism to add this function, which is very useful. But the problem is that it is not a supported product, but a "informal" method for providing supplementary functions. And there is still a threat to developers because the solution depends on formatting programs and channel scalability. All of this requires avoidance, to get functions, you must add an entry to the Remoting Configuration to illustrate using Windows NT Challenge / Response (NTLM). But such security mechanisms are likely to join .NET Remoting's future versions.

System services also need to be scalable and can be reused as a Remoting server because these functions will be required because multiple layers of distributed applications will need. For example, if there is no IIS, integration services will have to manage their audit and authorization, and both of these are IIS attached to standards.

For these reasons, the use of system service integration mechanisms is limited, and you have to use in a constrained environment. The news in this environment is queued for separate exchange, and security is not a problem, or you can use IPsec on TCP. .

Enterprise service management

In order for remote components to participate in the COM environment (and run in COM context), you need to inherit from ServiceDComponent. Other features provided in ServicedComponent and System.EnterpriseServices Namespaces allow CLR components to specify multiple COM properties, such as representative of transaction requirements and server processes. Plus the strict naming mechanism and use the regsvcs command, the remote component can be part of the entire COM environment.

Suppose the remote component needs to inherit from MarshalByrefObject, and the COM component needs to inherit from the servicedcomponent (and there is no multiple inheritance function in .NET managed code), how to achieve this? Fortunately, ServicedComponent is derived from ContextBoundObject, while the latter is derived from the MarshalByrefObject we need. Build a COM integration on Remoting is fully available, and it is indeed possible to obtain an apparent advantage provided by the enterprise service, such as the object pool, distributed transaction support, and role-based security. However, how to do this and such a method does what effect on future verification architecture, or not. We have reason to look forward to, with time, COM context infrastructure and Remoting's context infrastructure will be getting closer. But at this stage, how to do this and when this is not very clear.

Best method using Remoting

It has always been, not only project overhead, but also a headache of developers. The following guidelines are explored in practice, and it is not easy.

getting Started

Basic Remoting Task List provides a good start, which can be checked for the first setting of Remoting, which is best to perform this article as a reference for the entire process. Let's take a brief introduction to the steps to perform:

Host task

Design services, choose application domain, activation mode, channel, port, and release. Implement the Remoting host application domain (eg IIS / system service). Configure host activation, channels, and protocol settings. It is recommended to use the configuration file to load RemotingConfiguration.configure. Publish Interface for Client Use (see "Interface Publishing Selection" below) below for more information).

Client task

Design the client, select the application domain and activation mode. Consider whether you need registration channels and ports. Get remote type metadata. Implement the client application domain. Configure client activation mode and other types of information, such as application name, channel, and object URI, etc. It is recommended to use the configuration file to load RemotingConfiguration.configure.

Format selection

As a standard, Remoting can be configured to use SOAP or binary formatting programs on the HTTP channel, or use binary formatting procedures on TCP channels. In general, this configuration can be implemented in the client configuration file and invoke a static RemotingConfiguration.configure method.

For example, to configure the Remoting connection to use the binary formatting program on HTTP, you can complete the configuration entry as follows:

The "Channel REF" here refers to the message format to be sent on the channel, and "formatter Ref" refers to the message format to be sent on the channel.

Unfortunately, in the development process, the binary formatter is used for the HTTP channel, which generates the side effects of the blocking server-side error, for example, a general server error or access violation populates to the client. This is because when using a binary format, the client's Remoting component needs to return messages in a binary format. It does not correctly explain the wrong text of plain text, and reports the following error: Mscorlib.dll appears unprocessed exception type System.Runtime. Serialization. SerializationException. Additional information: BinaryFormatter version is not compatible. Requires version 1.0. The received version is 1008738336.1684104552.

This incorrect part is "not" because the version is not compatible, but because the client cannot analyze the wrong response of the text format. Although we believe this protocol defect can be resolved in the future version of the product, but it is also strong that you use the SOAP formatting program during the development process. After confirming, this formatting program can be switched to binary to enhance performance, but should be done in the performance advantage and necessary.

Interface release selection

After designing and constructing the Remoting server, the interface to be provided to the client is used to resolve the compilation reference and allow dynamically to create a proxy object. There are many ways to do this, it is necessary to repeat it. But there are a few prompts first:

Static fields and methods will never perform remote processing, and .NET Remoting always handles some form of instance members. Private method / type cannot be processed remotely. The MARSHALBYREF type is a derived type by reference to remote processing, and the type of sequence is replicated in the client process and executes code. Object virtual methods Equals, GetHashCode and MemberWiseClone, etc. are executed locally.

Learn about where these designs should be noted, you can choose to use the following methods to publish interfaces exported by the Remoting server:

Provide the server-side assembly to the client to compile. This method is not necessary when only interfaces are required without implementation. For the SOAP / HTTP client (the function of the Remoting server here is to provide web services, although there are some doubts about this service), the Remoting server can provide a Web Service Description Language (WSDL) file for the server object and method. The SOAPSUDS utility included with the .NET Framework SDK can be used to generate these WSDL files as metadata. In fact, this method is more suitable for web services (from strict ASMX sense) rather than remoting, because the WSDL of the Remoting interface cannot be fully compatible with WSDL of the Web service interface. SOAPSUDS TOOLS Dedicated .NET Framework Tools documentation details the SOAPSUDS utility. Declare an interface in separate libraries and deploy the library using the client. Release the server class that executes the interface, the client will be able to use it, the method is the agent that it is implemented. This is a very clear design choice because it is a particularly interested interface. This approach can only be used for server-activated objects (see Product Features), because unable to create an instance of the interface. Use SOAPSUDS to build an alternate class as a metadata. You can run SOAPSUDS for the Remoting server assembly to generate an output assembly (can be used as metadata) or source files (can be directly included in the application). This mechanism is useful for building multi-layer applications. In this application, the object in the layer is to access the remote object in another layer. This method is interesting, and this method is used in the multi-layer application referenced in the profile section of the above. Suppose we open a command window in the following folder:

$ FRAMEWORKSDK / Samples / Technologies / Remoting / Basic / RemotingHello / Service

We can write: soapsuds -id: .- Types: hello.helloservice, hello -oa: hellointerface.dll

This will create an output assembly Hellointerface.dll, which is included in the current directory's Hello program set is only based on the metadata based on the Remoting server hello.HelloService. The assembly can be used directly by the client. The location of the Remoting server is based on the standard Remoting configuration, which is derived based on the configuration data provided at runtime. MSIL generated for the client assembly

Ldfld Object [system.Runtime.Remoting] system.Runtime.remoting.Services.RemotingClientProxy ::_TP

Clearly show that we did not use the Remoting server implementation, but used a proxy class built by the metadata generated by SOAPSUDS.

You cannot ensure that SOAPSUDS is formatted using binary because it embedded / mapped some SOAP unique content in the output program centered data.

It is recommended that you try to keep the remote interface, using "enriched" instead of "fancy" interface, that is, try to limit the number of remote calls in the design. In some cases, this may need to pass redundant parameters. Place the remote interface in a separate class, distinguishes with the actual category. This can obtain a surface type mode: When needed, another technology can be easily replaced with the Remoting layer.

Management error

This section describes the errors that may be encountered during the development (and use) Remoting solution. In any case, you should remember to use and monitor methods to use standards. Event records are still very valuable information resources. Like the Network Monitor tool, the network monitor can specifically view the Remoting session of the client / server. The Remoting server of the intermediate layer can still use the standard debug tool provided by Visual Studio .NET to debug, for example, for Remoting servers integrated by IIS, you can add debugging sessions to the ASP.NET assist process (Debug [debugging " ] | Processes [Process] | Attach [Addition]) to set breakpoints (if resource is available). However, the transing error is very unique and some are listed below. Note that all versions of the Basic Remoting Hello Sample provided by the .NET Framework SDK have been recovered, and the server and clients have also run on a single machine. The fault phenomenon is the same as in the network link, but because the timeout setting of the HTTP / TCP is different, it is necessary to have an error. Lost MarshalByref

Because Remoting is to be used for a given class by reference, this class must do only one thing, that is, inheriting MarshalByrefObject. Suppose developers forget to do this, we will get an exception of a system.Runtime.Remoting.Remotingexception type, indicating that we have a "lost MarshalByreference".

Whether it can capture and deal with this RemotInGexception will depend on the programmer. (Think about this developer forgetting the only thing he should remember.)

Solution is to remember inheritance MarshalByrefObject!

Comfore well-known server activation error server endpoint

For server activation (see Product Features), the Remoting server declares its listening to endpoints. This endpoint typically includes an object URI (known as a known name of the remote object), an protocol and a port number. Of course, all of this may configure an error.

Incorrect URI

The URI of the Basic Remoting Hello Sample provided by the service is HelloService.SoAP, as specified in the relevant web.config file:

Objecturi = "HelloService.soap" />

This service is IIS integration. IIS integration requires the URI with suffix .rem or .soap, we use. Rope on the server. ROPE. In this example, we will receive RemotInGexception again. The text displayed this time is "Object has been disconnected or does not exist" on the server.

Make sure that each URI matches each other! When IIS integrates a Remoting server, make sure the URI ends with .rem or .soap. Missing protocol / port

In order to perform this test, we switch to the console integrated server, the following is the configuration file of the server:

Objecturi = "HelloService.soap" />

Suppose we have to change the protocol to TCP on the server, but keep the client HTTP.

We will receive RemotInGexception again, this text is "The underlying connection is closed: unexpected errors when receiving."

Port settings errors can also cause the above exception, the only difference in this case, and there is an error in the long time. The ports and protocols between the servers and clients must match.

Lost URI

Another possibility is that the remote server is not running, for example, the server is integrated by IIS, and the virtual application or related assembly is lost. Using the Basic Hello Remoting server again, we need virtual application Remotinghello to run. If we can't run, we will receive unprocessed exceptions (depending on the calling code), but this exception will be: "Unable to load type CLR: Hello.Hellooservice, Hello".

In these cases, make sure the virtual application is running, and the desired assembly is placed in the relevant BIN subfolder.

All in all, the client must correctly collect endpoints defined by the server to activate the server, which means that ports, protocols, and URI definitions must match each other. This is too easy to make an error. Therefore, if the location of the server is defined as:

Objecturi = "HelloService.soap" />

Then, the customer's settings must be:

URL = "http://localhost/remotinghello/helloservice.soap" />

Among them, the URL represents an IIS virtual application that integrates Remoting services, the type representation class and assembly name.

Remoting and ASP.NET Web Services IT design is also the worst thing is that there are too many architectural components that can be selected. Web services and .NET Remoting are in this case, sometimes it is difficult to determine which technology should be selected for different purposes. Of course, the correct answer is the best technology for the problem to be solved. Do not use "Always use web services" or "Web service is a subset of remoting, so it is equal to all Remoting" and other instructions. This section will mainly introduce these two technologies, indicating why it is to choose this more meaningful rather than another.

ASP.NET Web Services and .NET Remoting

Let us start from the definition of the web service, the definition says the web service is the service that can be available on the Web. This definition is not very useful, and we may take it to refine it into a "addressable processing unit through SOAP and HTTP, this processing unit is described in WSDL, which can be released through UDDI." This definition is much more Because it is separated by the web service and the web server to send HTML back to the browser. In order to compare with .NET Remoting, we especially emphasize the definition of the web service, which is different from the programming services that can be provided on the Web. For example, according to our definition, you can use the remote host accessible from the client from the client through HTTP. In view of this (and emphasizing Microsoft ASP.NET Web Service implementation), what factors should be considered when selecting ASP.NET Web Services and .NET Remoting's "combination"?

Interoperability

One common Microsoft Theory is: If interoperability is required, you should choose a web service method using open standard (SOAP, XML, HTTP), and use .NET Remoting to be resolved in an interactive solution; If all components in the various systems are CLR hosted, the .NET Remoting "Possible" is the correct choice. This principle has a wide range of applications, but it is still very useful. The client of the .NET remote object should be the .NET client. If your feature must be implemented on the web (web, the Internet), the web service will be the correct choice. Of course, intranet is not subject to this restriction: all clients can be .NET clients, and do not exclude .NET Remoting in this configuration. Similarly, for the intermediate layer of the application in the firewall and directly communicate with the web layer, you can still select .NET Remoting.

Powerful type support

.NET Remoting supports all managed types, classes, interfaces, enumerations, objects, etc., which are often referred to as "multi-type fidelity". The key here is that if the client and server components are objects that are running in the application domain, the interoperability of the data type is not problematic. Fundamentally, we have a closed system, and both ends of the session can be fully understood, so we can make full use of this fact, handle data types and objects for communication.

In the case where various systems coexist, we need to consider interoperability between systems. We must be careful for interoperable data types. For example, the definition of the web service data type is based on the description of the data type based on the XML schema definition (XSD). Any types that can be described using XSD and can be used on SOAP. However, this is indeed enabled some data types that cannot be used. For example, for unsigned characters or enumerations, there is no corresponding W3C XSD representation. For different web services, the processing of the collection, the processing of exceptions and data sets is also different. Another problem is that private fields and attributes are not passed between web service calls, which is not a key issue for fields and attributes itself, but if your system requires interoperability between different technologies, it is designed and This is a factor to consider when testing the system, because it can be sent to receive it. Repeat again, if interoperability is required between different systems, you should not consider using .NET Remoting technology. If it is a closed, CLR hosted solution, you can use it.

Status management

We have seen many ways to implement status management using .NET Remoting based on activation (client activation or singleton). For .NET Remoting and Web services, manage each client's connection status by http (with unstertable timeless stateless state) is a cumbersome and unrealistic thing. However, if you need to maintain a state, Remoting provides a solution based on each object. The Web service does not provide this connection status management of each client, but provides access to the ASP.NET session and application objects.

Living management

About status management is survival management. As we have seen, transoting provides a powerful mechanism for managing the life of the remote object. Web service objects exist and disappear with the call of Web services (from conceptual speaking, both synchronization and asynchronous). In this regard, the Web Services is a single call type compared to Remoting. Remoting provides a greater level of control over the activation and termination of the remote object. This may be meaningful for your design or meaningless.

Press value call and call according to reference

The object that passes to the web service call is serialized and passed by value. Objects passing to remoting or called object itself can be passed by value or by reference. The serialized remote object method is to process on the client. These differences should be considered when you choose between Remoting and Web services. Of course, these considerations are important to you, but also depends on the nature of the problem to be solved.

Supported protocol

The Web service call is limited to the SOAP encoded XML on HTTP. Remoting can use TCP to transfer, or extend infrastructure to support custom protocols. For example, the Jhawk User Sample section on www.gotdotnet.com provides a Remoting implementation using Named Pipe.

Here is a fragment of NamedPipe readme file, which clarifies the scalability of Remoting:

By implementing an IChannel * interface, you can use the pluggable channel structure to insert the channel into .NET Remoting.

Named PIPE channel supports the following features:

* Communication via naming pipeline

* Synchronous message

* Asynchronous message

* One way message

* Callback

* Channel reception

* Channel properties

* Automatically generate pipe names

Therefore, if you need NAMED PIPE, Remoting can provide a solution. However, like SSPI NTLM authentication solutions, Microsoft does not support this solution, perhaps future Microsoft will meet this needs. performance

If performance is really critical to your design, Remoting, used TCP, indeed provides some significant performance advantages. For the results described herein, if you want to completely understand the test environment and tests that generate this result, see Performance Comparison: .NET Remoting with ASP.NET Web Services.

Here is some of the performance statistics summed up from this article:

Legend: ASMX - Web Services, others are Remoting Solutions

WS represents a Windows service that integrates remote components.

Figure 1: Performance statistics

The article is explained next to the performance chart, as described below:

"As shown above, for WS_TCP_BINARY, the object is configured to use TCP channels and binary formatting programs, and the host is Windows service, which is better than other distributed technology. This is because the method passes the original TCP The word transmission binary data (high efficiency than HTTP), and the data does not require encoding / decoding, thereby reducing system overhead. It can be seen that there is about 60% of the performance gap between WS_TCP_BINARY and the slowest method.

Although IIS_HTTP_BINARY is the same as the binary load generated by WS_HTTP_BINARY, it has a slower speed because there is an additional process hop from IIS (inetinfo.exe) to ASPNET_WP.EXE. The performance difference between IIS_HTTP_SOAP and WS_HTTP_SOAP is also caused.

The performance of WS_HTTP_BINARY and WS_TCP_SOAP is almost the same. Although the former has an additional system overhead of HTTP analysis, the latter has additional system overhead in SOAP analysis, but in this example, the system overhead of HTTP analysis is almost the same as the SOAP analysis system overhead.

The performance of the ASP.NET Web service is better than IIS_HTTP_SOAP and WS_HTTP_SOAP because the ASP.NET XML serialization is higher than the .NET Remoting SOAP serialization. As can be seen from the above, the performance of the ASP.NET Web service is almost the same. "

If the original speed is really very important, then this "60% performance gap" is very meaningful. The disadvantage is to integrate the server in a Windows service to use the TCP protocol (see the previous remote integration section). It effectively weighs performance security and is a method that best not used for Internet or unsafe intranet.

summary

The ASP.NET Web service is based on XML, which is used to request simple programming mode and powerful cross-platform support using HTTP (assuming their integration in IIS). It provides a certain degree of scalability by using SOAPEXTensions. For example, an encrypted data stream. Remoting's programming mode is more complicated, but in terms of protocol and message format, it has a significant advantage in terms of type fidelity, state management, and scalability. Remoting cannot be used for non-.NET clients, so the Internet client cannot be implemented directly to the remote host. Remoting cannot provide a security model when integrated outside IIS. When integrated in IIS, Remoting provides the same security features as ASP.NET, including security protocols such as SSL. If you don't need to consider interoperability with other platforms, and the client and server configuration is completely under your control, you can consider using .NET Remoting. Using Remoting, IIS integration using HTTP channels is better than non IIS integration so that it can benefit from the relevant security and scalability infrastructure. Of course, this means you have to interoperate with IIS in the solution. If this is unable to implement, then transnet "possibilities" is the difficult task that is unable to implement, which is related to the nature of the problem to be solved. Since .NET Remoting requires the use .NET client, it is necessary to use the fastest available formatting program, so that binary is selected without choosing SOAP will produce better performance. Remember the recommended recommendations of the best method of the above, use this formatting program while publishing, instead of using it during development. Summary

.NET Remoting is a valid tool used in some distributed solutions that provides scalable models in supported protocols and message formats and can provide performance advantages in specific situations. It should not be deployed directly on the Internet, and its server objects should be integrated under IIS to take advantage of the security and performance characteristics provided by IIS as the process running under its control.

For "closed" distributed solutions, the clients and servers are CLR hosting processes, and should consider using Remoting. For example, an Intranet solution uses a security TCP channel (such as IPSec) or any layer of any layer of HTTP, or through the firewall and an intermediate application component of the .NET Web layer component session. In this case, after confirming the application using the SOAP formatting program, you should select the binary formatter and HTTP channels.

For systems to interoperate with non-CLR clients, use the ASMX web service, but should be carefully handled (see powerful type support).

Please note that using TCP integration outside IIS will bring performance advantages, but you need to customize security.

Design and implementation

Realizing and configuring remoteing is a fairly easy process. In this process, first select the Remoting host, protocol, and activation mode. Please try to simplify the design and implementation process and carefully consider which interface publishing mechanism is the most meaningful for your solution. The recommended method is to release the interface as the most readily understood model, but this cannot be used to activate the object. Debugging procedures, event logs, and network monitoring are a very useful tool during the development process. When developing remote components, they can also help you.

Remoting's future

Issues that "when using remoting, when to use Web services" is difficult to answer, not to mention the definition of terms is not very clear. For example, if the definition of the web service is unclear, Remoting is likely to be configured as a Web service. Perhaps Remoting and ASMX technology will gradually fuse. But at present, we can at least reasonably explain to where to use which technique is used, as described above.

Current development focuses on providing GXA implementations for routing, security, and transaction support. This implementation is based on the use of the SOAP header, and the current direct goal is to extend the functionality of the web service. Although as described herein, from the traditional sense, GXA does not support .NET Remoting, but it supports many problems such as status and transaction management. Although the current GXA implementation can solve many of the problems faced by the Web service, its most fundamental purpose is to solve these problems in a way that does not require too high technical content. Seeing the impact of GXA's development on Web services and .NET Remoting, it will be a fun thing.

Other resources

Accessing Objects in Other Application Domains using .NET Remoting (English) Microsoft PAG Building Secure ASP.NET Applications, Chapter 11: Remoting Security (English) Enterprise: Remoting reading list (English) ASP.NET Web Services or .NET Remoting: how to choose

转载请注明原文地址:https://www.9cbs.com/read-32407.html

New Post(0)