Custom Proxies Technology Sample

Download Sample

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).

This sample demonstrates the extensibility of the RealProxy class. By extending RealProxy, user code gains access to the messages that are transported to and from any remote object. The sample creates three executable files. The ProxyWithReturnMessage.exe application overrides the Invoke method to display message data. The ProxyWithCustomCasting.exe application uses two interfaces, named IFaq and IBaz, to demonstrate custom casting capabilities. The ProxyWiredToHttpChannel.exe application shows how to intercept and forward the call to the RemotingHello service using the Http Channel.

Important Note:
This sample requires that Internet Information Services (IIS) be installed on your computer. You must register the RemotingHello service with IIS before running sample applications.

To build the sample using the Command Prompt

  1. Open a Command Prompt window and navigate to the CS subdirectory.

  2. Type msbuild CustomProxiesCS.sln at the command line.

    Note

    This sample builds three console applications. You must launch and run them using the command prompt in order to view their output.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to the CS subdirectory.

  2. Double-click the icon for CustomProxiesCS.sln to open the file in Visual Studio.

  3. On the Build menu, choose Build Solution.

To register the service in IIS

  1. Compile the service to a DLL and copy this DLL to a bin directory where the service will be loaded from. Building the sample using the Command Prompt or Visual Studio as described above compiles the service, creates the bin subdirectory under ProxyWiredToHttpChannel and copies Hello.dll there.

  2. Start Internet Services Manager and select Default Web Site under the server node. Select Action, New, Virtual Directory on the menu and click Next to continue.

  3. Enter RemotingHello as the alias and press Next.

  4. Enter the directory where the service is located. Enter the full path up to but excluding the bin directory where the dll in step 1 was copied to.

  5. Press Next. Accept the defaults presented and press Next again. Press Finish. The service has now been registered and will appear under the list of Default Web Sites in the Internet Services Manager window.

  6. Ensure that there is a web.config file in the directory where the service was registered. This file describes your service and will automatically be loaded when a client attempts to access your service with a browser or client using the HTTP channel on port 80.

To run the sample

  1. Navigate to the directory that contains one of the three executable files:

    • ProxyWiredToHttpChannel.exe

    • ProxyWithCustomCasting.exe

    • ProxyWithReturnMessage.exe.

    Each executable is located in the \bin\Debug subdirectory under the directory with the same name as the console application.

  2. Type the name of the executable file at the command line. Ensure that the RemotingHello service is registered with IIS as described above before running ProxyWiredToHttpChannel.exe.

See Also

Reference

IChannel
IMessage
IRemotingTypeInfo
MarshalByRefObject
OneWayAttribute
RealProxy
System.Collections
System.Runtime.Remoting
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Messaging
UnmanagedType

Concepts

Extending RealProxy

Other Resources

Advanced Remoting
Object Activation and Lifetimes