ARTICLE

Remoting Configuration in VB.NET: Part 2

Posted by Sapna Articles | Visual Basic Language September 22, 2010
In this article I will explain you about VB.NET Remoting Configuration.
 
Reader Level:

See Part 1
We have used a template for the <channels> element. How is this beneficial? The id attribute in the <channel> element provides a label that can be referred to in the <application> section. Notice, also, the template is outside the body of the <application>. The <channel> tag attribute ref is the link to channel information. This allows us to create a common file for both the server and the client. In the example in Listing 25.22, the template is in the same file, but in the real world, the scenario would likely be in the format shown in Listings 25.23 and 25.24.

Listing 25.23: The Common Template Configuration File


<?
xml version="1.0" ?>
<
configuration>
          <
system.runtime.remoting>
                   <
channels>
                             <
channel id="Http Server"
                            
name="Server Activated"
                            
type="System.Runtime.Remoting.Channels.Http.HttpServerChannel, System.Runtime.Remoting"/>
                   </
channels>
          </
system.runtime.remoting>
</
configuration>

Listing 25.24: The Server's Configuration File


<?
xml version="1.0" ?>
<
configuration>
          <
system.runtime.remoting>
                   <
application name="ServerActivatedServerExe">
                             <
service>
                                      <
wellknown
                                     
mode="SingleCall"
                                     
type="SimpleObjectLib.SimpleObject, SimpleObjectLib"
                                     
objectUri="Simple">
                                      </
wellknown>
                             </
service>
                             <
channels>
                                      <
channel ref="Http Server" port="1234"/>
                             </
channels>
                   </
application>
          </
system.runtime.remoting>
</
configuration>

To access these two files is simply a matter of calling as follows:

RemotingConfiguration.Configure( template configuration file name)
and
RemotingConfiguration.Configure( server's configuration file name)

RemotingConfiguration reads the directives in the template and applies them to the <application> segment whenever it encounters a ref attribute. The usefulness of this approach will become evident when configuring custom channel sink providers, discussed later in the coming article.

Server-activated objects (Listing 25.24) are distinguished from client-activated objects by the <activated> element's corresponding tag <wellknown>. The <wellknown> element's attributes mode, type, and objectUri mirror the parameters in earlier source code. It should be apparent that this is a server configuration file from the <service> tag.

The examples in this chapter were initially coded using Visual Studio .NET Beta2. RemotingConfiguration.Configure behaves differently in the release candidate. Listing 25.22 executed as expected in Beta2, loading the remoting DLL located in the global assembly cache (GAC). The release candidate, however, threw a "File Not Found" exception. This was unexpected behavior for an assembly in the GAC. To overcome this, highlight the remoting DLL and change Copy Local in properties to true.

Figure 25.15: Project Properties

Figure-25.15.gif

The client configuration file for server-activated objects differs only slightly from the clientactivated configuration (see Listing 25.25).

Listing 25.25: ServerActivatedClientExe.exe.config


<?
xml version="1.0" ?>
<
configuration>
          <
system.runtime.remoting>
                   <
application name="ServerActivatedClientExe">
                             <
client url="http://localhost:1234/Simple">
                                      <
wellknown
                                     
type="SimpleObjectLib.SimpleObject, SimpleObjectLib"
                                     
url="http://localhost:1234/Simple">
                                      </
wellknown>
                             </
client>
                             <
channels>
                                      <
channel ref="Http Client"/>
                             </
channels>
                   </
application>
          </
system.runtime.remoting>
</
configuration>

The <wellknown> tag contains the ever-present type attribute. The additional url attribute seems redundant because of the <client> element url attribute. Don't be misled. The <wellknown> element's url attribute is mandatory, whereas in this case the <client> element's url is optional.

Conclusion

Hope this article would have helped you in understanding VB.NET Remoting Configuration.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor