ARTICLE

Remoting over the Web in VB.NET

Posted by Manish Tewatia Articles | Visual Basic Language October 04, 2010
In this article I will explain you about Remoting over the Web in VB.NET.
 
Reader Level:

It is also possible for Internet Information Server (IIS) to host remote objects.The console client project is named WebClientExe.

To use IIS as a server, you must take a number of steps:

  • The remote object must be server activated.

  • Map a virtual directory, on the Web server, to the SimpleObjectLib folder.

  • The remote object can't be programmatically configured. It must use a web.config file in the virtual directory's root, see Listing 25.26.

Listing 25.26: Web.config

<?
xml version="1.0" ?>
<
configuration>
      <
system.runtime.remoting>
            <
application>
                  <
service>
                        <
wellknown
                       
mode="SingleCall"
                       
type="SimpleObjectLib.SimpleObject, SimpleObjectLib"
                       
objectUri="Simple.rem">
                        </
wellknown>
                  </
service>
                  <
channels>
                        <
channel
                       
name="Server-Activated Web Client"
                       
type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting"/>
                  </
channels>
            </
application>
      </
system.runtime.remoting>
</
configuration>

You should be aware of a number of items in the configuration file:

  • No port number need be specified, as IIS has already been configured to listen on a port, normally port 80.

  • The objectUri attribute in the wellknown element must use the extension .rem or .soap.

    The client code remains the same as previous server-activated examples (see Listing 25.27). The client output is shown in Figure 25.16.

Listing 25.27: WebClient.vb

      Protected
Sub Calendar_Selection(ByVal sender As [Object], ByVal e As EventArgs)
        ChannelServices.RegisterChannel(New HttpChannel())
        Dim simple As SimpleObject = Nothing
        simple = DirectCast(Activator.GetObject(GetType(SimpleObject),
        "http://localhost/WebRemoting/Simple.rem"), SimpleObject)
        Dim ret As String = Nothing
        ret = simple.ConCatString("using the", "Web for remoting.")
    End Sub


Figure 25.16: WebClientExe Output

Figure-25.16.gif

Conclusion

Hope this article would have helped you in understanding Remoting over the Web in VB.NET.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    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.
Become a Sponsor