.NET
  Home arrow .NET arrow Page 9 - .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 - BankPackage.dll: Contract Between Clients and Servers


    (Page 9 of 11 )

    If you're familiar with COM, you'll be accustomed to creating type libraries. The type library is a standardized binary resource linked in your server's executable or DLL that Windows requires to enable for interprocess communication. The type library represents the contract between your server and clients: It tells clients what they can do and what complex data types they will be using, but it contains no implementation.

    When you develop .NET Remoting servers, type libraries are not necessary anymore: .NET's metadata included inside the compiled package will serve this purpose. The BankPackage.dll we just created is a .NET assembly that will contain the shared interfaces and classes used by the server and the client application.

    We've added a new unit to BankPackage.dll and saved it as BankShared.pas. This unit is shown in Listing 29.1.

    Listing 29.1 The BankShared.pas Unit

    1:  unit BankShared;
    2: 
    3:  interface
    4: 
    5:  type
    6:   { TAccount }
    7:   [Serializable]
    8:   TAccount = class
    9:   private
    10:   fNumber : integer;
    11:   fBalance: double;
    12:   fName: string;
    13:
    14:  public
    15:   constructor Create(const aNumber : integer;
    16:             const aName : string;
    17:             const aBalance : double);
    18:
    19:   property Number : integer read fNumber;
    20:   property Name : string read fName;
    21:   property Balance : double read fBalance write fBalance;
    22:  end;
    23:
    24:  { IBankManager }
    25:  TAccountNumberArray = array of integer;
    26:
    27:  IBankManager = interface
    28:   function GetAccountNumbers : TAccountNumberArray;
    29:   function GetAccount(const AccountNumber : integer) : TAccount;
    30:   procedure TransferMoney(const Origin, Destination : integer;
    31:               const Amount : double);
    32:  end;
    33:
    34: implementation
    35:
    36: { TAccount }
    37:
    38: constructor TAccount.Create(const aNumber : integer;
    39:             const aName : string;
    40:             const aBalance : double);
    41: begin
    42:  inherited Create;
    43:
    44:  fNumber := aNumber;
    45:  fName := aName;
    46:  fBalance := aBalance;
    47: end;
    48:
    49: end.


    Find the code on the CD: \Code\Chapter 29\Ex01.


    In Listing 29.1, the IBankManager interface is a critical aspect of this unit (lines 24–32). As you can see, there isn't any class implementing it. This package is going to be shared between server and client, but the client doesn't need to know about (or contain) any implementation details. All it needs to know is what and how to call it.

    The only class defined and implemented in this unit is TAccount (lines 6–22 and 38–47). In addition to this, the array TAccountNumberArray is also declared (line 25).

    Because these two types are referenced by the methods of IBankManager, they need to be included in the shared assembly.

    The interface IBankManager is implemented in the server project.

    The other important thing to notice is the use of the attribute [Serializable] above the class TAccount (line 7). If TAccount was not marked as serializable, IBankManager.GetAccount would fail at runtime when called remotely.

    TAccount is used as a Marshal-By-Value object. When the remote client calls GetAccount, a copy of the object is passed across application domain boundaries.

    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 6 hosted by Hostway
    Stay green...Green IT