.NET
  Home arrow .NET arrow Page 5 - .NET Remoting and Delphi
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

.NET Remoting and Delphi
By: Xavier Pacheco
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2004-08-09

    Table of Contents:
  • .NET Remoting and Delphi
  • Distributed Architectures
  • Benefits of Multitier Application Development
  • .NET Remoting Basics
  • The ChannelServices Class
  • Object Activation
  • Your First .NET Remoting Application
  • Adding References
  • BankPackage.dll: Contract Between Clients and Servers
  • Implementing the Server
  • Implementing the Client

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    .NET Remoting and Delphi - The ChannelServices Class


    (Page 5 of 11 )

    The ChannelServices class provides static class methods to register remoting channels, and it's used in both clients and servers.

    The following snippet of code shows how to create and register an HTTP communication channel listening on port 9088 for use on the server side:

    var Channel : HttpChannel;
    begin
    Channel := HttpChannel.Create(9088);
    ChannelServices.RegisterChannel(Channel);

    Clients do not specify a port number when registering channels. The URI information necessary to access remote objects is specified in the call to the Activator object at a later time, and this will also include a port number.

    The following snippet of code shows how to create a client channel and acquire a reference to the remote service from the client application:

    type
    TCalculator = class(MarshalByRefObject, ICalculator)
    private
    protected
      // ICalculator
      function Sum(A,B : integer): integer;

    public
    end;

    Remotable Objects

    Objects intended to be accessed by different domains are called remotable objects. Two types of remotable objects exist in .NET: Marshal-By-Reference, and Marshal-By-Value.


    Note - A third type, Context-bound is also available, but it won't be covered in this book because of the length and complexity of the topic. You can think of a .NET context as a subdivision of an application domain in which context-bound objects live. For more information about Contexts, refer to the .NET Framework SDK Documentation at "ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/
    cpconremotableobjects.htm"
    .


    Marshal-By-Reference Objects

    Simply put, instances of this type can be seen as a collection of methods that can be invoked from remote clients.

    Marshal-By-Reference objects are created on the server where they live for the duration of a method call (see "Single-call Instantiation" later) or are shared among different clients (see "Singleton Activation" later) for the duration of a lease (see "Leases and Sponsors" later).

    In order to create a Marshal-By-Reference object, you need to make its class descend from MarshalByRefObject, which is defined in the System namespace.

    The following is an example of a Marshal-By-Reference class:

    type
    TCalculator = class(MarshalByRefObject, ICalculator)
    private
    protected
      // ICalculator
      function Sum(A,B : integer): integer;

    public
    end;

    The methods of this type of objects can have any kind of simple data type (that is, integers, strings, and so on) or object parameters(as long as they are Marshal-By-Value objects).

    Marshal-By-Value Objects

    Instances of this type cross application domain boundaries after being serialized in a transportable format.

    When they reach the target domain, they are deserialized and a new instance of the original class is created in the target application domain.

    In order to create a serializable object, you need to mark its class with the [Serializable] attribute like this:

    { TAccount }
    [Serializable]
    TAccount = class
    private
      fNumber : integer;
      fBalance: double;
      fName: string;

    public
      constructor Create(const aNumber : integer;
                const aName : string;
                const aBalance : double);

      property Number : integer read fNumber;
      property Name : string read fName;
      property Balance : double read fBalance write fBalance;
    end;

    The purpose of these types of objects is generally to share data between applications in a structured manner. They are usually used as input or output parameters of remote methods.

    This chapter is from Delphi for .NET Developer's Guide, by Xavier Pacheco (Sams, 2004, ISBN: 0-672-32443-1). Check it out at your favorite bookstore today.

    Buy this book now.

    More .NET Articles
    More By Xavier Pacheco


       · in time compiling is message:Incompatible types 'IBankManager' and 'Object'where...
       · is in WinformfBankManager := Activator.GetObject( typeof(IBankManager), ...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT