Library tutorials & articles

A Simple Introduction to .NET Remoting

Host Application

To enable client applications to use our remotable object we need to build a Host application which will listen for object requests. This application will register a channel and register our remotable object with the .NET remoting system to use that channel to listen for requests.

.NET includes two default channels:

  • HttpChannel (using SOAP formatting)
  • TcpChannel (using binary formatting)

NOTE: Because remote configuration is done on a per-application-domain basis, the application domain must be running to listen for requests.

Create a console application project called "RemotingHost". Add a reference to our RemotableType and add the following class.

using System;
using System.Runtime.Remoting;
public class RemotingHost
  public static void Main(){
    RemotingConfiguration.Configure("RemotingHost.exe.config");
    Console.WriteLine("Host Running. Listening for Object Requests.");
    Console.ReadLine();
  }
}

You can configure .NET remoting through code or via a configuration file. In this example we are using app.config so add a app.config file to you project and add the following entries:

<configuration>
  <system.runtime.remoting>
      <application>
        <service>
            <wellknown
              mode="Singleton"
              type="RemotableType, RemotableType"
              objectUri="RemotableType.rem"
            />
        </service>
        <channels>
            <channel ref="http" port="8989"/>
        </channels>
      </application>
  </system.runtime.remoting>
</configuration>

Our Host class loads the config information from the app.config file using the RemotingConfiguration.Configure() method.

Comments

  1. 14 Sep 2005 at 10:49

    hi,
    i have an xml file


    <?xml version="1.0"  ?>
    <users>
        <User id="u1">
       <UserName>user1</UserName>
       <Password>pwd1</Password>
        </User>
        <User id="u2">
       <UserName>user2</UserName>
       <Password>pwd2</Password>
        </User>
    </users>


    i want to read this file in c#.net and  compare the username with username entered in textfield while logging.
    can you help me?

  2. 14 Sep 2005 at 10:47

    hi,
    i have an xml file


    <?xml version="1.0"  ?>
    <users>
        <User id="u1">
       <UserName>user1</UserName>
       <Password>pwd1</Password>
        </User>
        <User id="u2">
       <UserName>user2</UserName>
       <Password>pwd2</Password>
        </User>
    </users>


    i want to read this file in c#.net and  compare the username with username entered in textfield while logging.
    can you help me?

  3. 14 Sep 2005 at 10:47

    hi,
    i have an xml file


    <?xml version="1.0"  ?>
    <users>
        <User id="u1">
       <UserName>user1</UserName>
       <Password>pwd1</Password>
        </User>
        <User id="u2">
       <UserName>user2</UserName>
       <Password>pwd2</Password>
        </User>
    </users>


    i want to read this file in c#.net and  compare the username with username entered in textfield while logging.
    can you help me?

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of A Simple Introduction to .NET Remoting.

Leave a comment

Sign in or Join us (it's free).

Lee Gunn - .NET C# Scotland Lee Gunn is a freelance Microsoft Certified Developer based in Glasgow, Scotland. Specialising in quality driven Internet solutions, largely built around Microsoft’s .NET platform. Skills used o...
AddThis

Related discussion

Related podcasts

  • More jQuery in ASP.NET

    In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, and Scott Koon conclude their discussion of Microsoft's jQuery in ASP.NET announcement1.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are ...

Events coming up

  • Nov 18

    15 Minutes of Fame

    Dresher, United States

    This is a yearly tradition. We select 10 of the favorite speakers from monthly meetings, code camps, and hands on labs. Each one does a 15 minute talk on their favorite .NET technology. This is our 10th anniversary so we plan a gala event with special prizes and refreshments.

We'd love to hear what you think! Submit ideas or give us feedback