CHAPTER 18 584 THE .NET REMOTING LAYER Remoting Configuration Files At this point you have successfully built a distributed application using the .NET remoting layer. One issue you may have noticed in these first examples is the fact that the client and the server applications have a good deal of hard-coded logic within their respective binaries. For example, the server specifies a fixed port ID, fixed activation mode, and fixed channel type. The client, on the other hand, hard-codes the name of the remote object it is attempting to interact with. As you might agree, it is wishful thinking to assume that initial design notes remain unchanged once an application is deployed. Ideally, details such as port ID and object activation mode (and whatnot) could be altered on the fly without needing to recompile and redistribute the client or server code bases. Under the .NET remoting scheme, all the aforementioned issues can be circumvented using the remoting configuration file. As you will recall from Chapter 11, *.config can be used to provide hints to the CLR regarding the loading of externally referenced assemblies. The same *.config files can be used to inform the CLR of a number of remoting-related details, on both the client side and the server side. When you build a remoting *.config file, the element is used to hold various remoting-centric details. Do be aware that if you re building an application that already has a *.config file that specifies assembly resolution details, you re free to add remoting elements within the same file. Thus, a single *.config file that contains remoting and binding information would look something like this: If your configuration file has no need to specify assembly binding logic, you can omit the element and make use of the following skeleton *.config file: Building Server-Side *.config Files Server-side configuration files allow you to declare the objects that are to be reached via remote invocations as well as channel and port information. Basically, using the , , and elements, you are able to replace the following server-side logic: // Hard-coded HTTP server logic. HttpChannel c = new HttpChannel(32469); ChannelServices.RegisterChannel(c); RemotingConfiguration.RegisterWellKnownServiceType( typeof(SimpleRemotingAsm.RemoteMessageObject), “RemoteMsgObj.soap”, WellKnownObjectMode.Singleton); with the following *.config file:
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.