Custom Proxies Technology Sample
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. |
For information about using the samples, see the following topics:
To build the sample using the Command Prompt
Open a Command Prompt window and navigate to the CS subdirectory.
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
Open Windows Explorer and navigate to the CS subdirectory.
Double-click the icon for CustomProxiesCS.sln to open the file in Visual Studio.
On the Build menu, choose Build Solution.
To register the service in IIS
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.
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.
Enter RemotingHello as the alias and press Next.
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.
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.
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
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.
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
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Messaging