次の方法で共有


Basic Remoting Task List

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

.NET remoting is one of several ways to establish communication between application domains using the .NET Framework. You must decide which features your application requires and consider the resources you have at your disposal before choosing a particular development model for your distributed application. For more information, see Choosing Communication Options in .NET . The following task lists describe the fundamental steps required to build a basic .NET remoting application.

Remotable Type Tasks

Define the remotable type. Remotable types must derive from MarshalByRefObject. The assembly that contains the remotable type must be referenced by the client application as well as the server application. If you do not want the client application to reference the implementation assembly, you can generate a stub assembly by using the soapsuds.exe tool and reference it with the client application. Alternatively you can define an interface in a shared assembly, implement that interface on the remote object, and reference the shared assembly in the client application. The only drawback to this method is when using a configuration file to configure the client you cannot use the new operator to instantiate a remote object. You must call GetObject to instantiate the remote object.

Host Tasks

To publish any remote object for use from outside your application domain

  1. Design the service.

    1. Choose a host application type, see How to: Build a Hosting Application.

    2. Choose an activation mode, see Activation of Remote Objects.

    3. Choose a channel and port, see Choosing a Channel.

  2. Implement the host application. Remoting hosts can be Windows Services, console applications, Windows Forms applications, Internet Information Services (IIS) processes, or ASP.NET applications. Requirements for each type of application vary, so you should read the documentation that describes how to build the type of application you want to use. For more information, see Windows-based Applications or ASP.NET Web Applications in the .NET Framework. In the host, configure the remoting system for activation mode and other information, such as application name and object URI. If you want to programmatically configure the system, you do not need to use a configuration file. If you use a configuration file, you must load that file into the system by calling RemotingConfiguration.Configure.

  3. In the host, create the appropriate channel and register it with the system by calling ChannelServices.RegisterChannel. If you use a configuration file, you must load that file into the system by calling RemotingConfiguration.Configure.

  4. The host must reference the remote object's assembly.

Client Tasks

To consume any service for use from outside your application domain

  1. Design your client.

    1. Choose a client application domain.

    2. Determine the activation mode and either the client activation URL or the well-known object URL of the remote type.

    3. Consider whether you need to register a channel and port.

    4. Obtain the remote type's metadata.

  2. Implement your client application. Remoting hosts can be Windows Services, console applications, Windows Forms applications, Internet Information Services (IIS) processes, or ASP.NET applications. Requirements for each type of application vary, so you should read the documentation that describes how to build the type of application you want to use. For more information, see Windows Applicationsor ASP.NET Web Applications in the .NET Framework.

  3. Configure the client remoting system with the activation mode and other type information, such as application name and object Uniform Resource Identifier (URI). If you want to programmatically configure the system, you do not need to use a configuration file. If you use a configuration file, you must load that file into the system by calling RemotingConfiguration.Configure.

  4. Create the appropriate channel and register it with the system by calling ChannelServices.RegisterChannel. If you use a configuration file, you must load that file into the system by calling RemotingConfiguration.Configure.

  5. Instantiate and call the remote object. If the object was configured with a configuration file you can use the new operator. If the object was configured programmatically you can call GetObject.

See Also

Concepts

Choosing Communication Options in .NET

Other Resources

Building a Basic .NET Framework Remoting Application
.NET Framework Remoting Overview
Remoting Examples