chapter 7 com and .net.ppt - bhushan jadhavbhushanjadhav.webs.com/notes and ppts/chapter 7...

53
1

Upload: vankhanh

Post on 01-Apr-2018

252 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

1

Page 2: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

CHAPTER 7 COM and .NET— Evolution of DCOM— Introduction to COM— COM clients and servers— COM IDL & COM Interfaces— COM Threading Models.— Marshalling, Custom and standard marshalling.— Marshalling, Custom and standard marshalling.— Comparison COM and CORBA.— Introduction to .NET.— Overview of .NET architecture— .NET Remoting.

2

Page 3: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Evolution of COM

— COM is a Component Model Developed by Microsoftnamely Component Object Model.

— To Support distributed application Microsoft usesMicrosoft Distributed Component Architecture (MDCA).

3

Microsoft Distributed Component Architecture (MDCA).MDCA used Distributed COM i.e. DCOM

Page 4: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Evolution of COM1)Clipboard -:Initially clipboard was used as fundamental

method for sharing data between two applications.2)Dynamic Data Exchange-:In 1990 DDE was primarily

used for dynamically exchanging data between twoapplications. It was used in office applications. As it buildat the top of Message passing architecture of windows, itwas slow, hard to program, inflexible.

4

was slow, hard to program, inflexible.3)OLE 1.0 -:DDE evolved to OLE 1.0.OLE was capable of

maintaining active links between two documents or evenembedding one type of document in to another. it usesDDE for interprocess Communication.

4)16 bit OLE -: used in VB2.0 & MSOFFICE 4.0 usesVirtual function table to communicate client & server

Page 5: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Evolution of COM5)OLE 2.0 -:Introduced in 1993 , it’s a reimplementation of

OLE 1.0 using COM instead of VTBL.COM is a binarystandard Specifies how to communicate with Objects,Control Object lifecycle & expose functionality to user

6)OCX -: OCX is a OLE Control used in VB 4.0 usescontainer to load it. Container & OCX Communicatewith each other through interfaces.

5

with each other through interfaces.7)ActiveX -: it’s a Light weighted COM Object. Deals with

active content management of web Pages.8)DCOM -:DCOM uses ms RPC for communication with

remote System.DCOM extends COM by marshaling thearguments & return value of method call over theNetwork.

Page 6: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Evolution of COM9)COM +-:Introduced to handle functionality of Microsoft

Transaction server(MTS).10).NET -: it provides rapid development tools for both

windows form & web forms.11).NET Remoting -:Allows objects to be transparently

marshaled by reference or values across machinesboundaries. it uses MS API to send message from client

6

boundaries. it uses MS API to send message from clientprocess to server process & to receive reply in assistanceof OS & network agents.

Page 7: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Introduction to COMØTraditional Monolithic Applications we distributed as

single like.exe they needed to rebuild even if one line ofcode changed

ØComponent oriented Design solved this problem bybreaking application down into components that can bedistributed in separate binary files like DLL or exe.

ØCOM enables developer to package their functions into

7

ØCOM enables developer to package their functions intoreusable software Components.

ØIt defined Standard architecture & protocol forinteracting objects on heterogeneous platforms.

ØIt provides Location transparency to objects so that ituses Remote procedure call (RPC) for Remote instanceof Object

Page 8: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Introduction to COMØAn application can interact with each other through

interfaces.COM object must support at least one baseinterface called IUnknown.

ØThe use of interfaces are1)Fast & Simple object interaction2)Location transparency3)Programming language independence

8

3)Programming language independence4)It’s a true Object Model as it provides Distributed

Capablities,Provide Object level Security, encapsulatelifecycle of objects, provide methods for reusability etc.

5)Provide evolution of Application Functionality

Page 9: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM Clients & ServerØA COM is a body of Source code that implements COM

interface. It has Class identifier(CLSID) & interfaceidentifier (IID).

ØOne or more COM classes are packaged into Server. ACOM server can be packaged as DLL or EXE.

Ø1) If it packaged as DLL that is loaded in to client

9

Ø1) If it packaged as DLL that is loaded in to clientprocess & accessed by server called in-process server.

Ø2) If it packaged as EXE that is Run on same as a clientor remote machine that is accessible through DCOMcalled Out-of-process Server.

Page 10: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM Clients & ServerØ On the basis of packaging they are of 4 types

Ø 1)In-Process Server -: if the component is a local & designed to bean in process server the client instantiate it & Communicatethrough COM. e.g. ActiveX

Ø 2)Out-of-Process Server -: if the component is a local & designedto be a local out-of process server ,the client instantiate it &Communicate through COM,Proxies & registry. E.g. Excel

Ø 3)Out-of-Process Remote Server -: if the component is Remote but

10

Ø 3)Out-of-Process Remote Server -: if the component is Remote butclient did not specify Remote System, then client registry containname of machine on which component is created. TheyCommunicate using DCOM.

Ø 4)In-Process Remote Server -: if the Remote component is writtento take advantage of MTS,it can run in-process to MTS & usesDCOM to communicate clients.

Page 11: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Types of COM Server

Page 12: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM— DCOM is also called as COM on Wire supports Remoting

objects by using objects remote procedure call (ORPC) protocol

— This ORPC layer is built on top of DCE’s RPC & interact with COM’s runtime services

— To invoke remote function Client make a call to client stub .stub packs the call parameters in to request message to server..stub packs the call parameters in to request message to server.

— At server side wire protocol delivers the message to server stub which then unpack the request message & call actual function on Object.

— In DCOM Client stub is referred as Proxy & server stub is stub.

12

Page 13: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM Architecture

13

Page 14: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM Architecture— The Architecture of DCOM Consist of three layers Top,

Middle & Bottom layer.

— The Top layer is the basic programming Architecture. It describes Clients requests & creation of object instance in the Server transparent to client.

— In DCOM creation of remote object requires the server name & CLSID.The SCM in COM libraries on client machine connects to the SCM on server machine & requests creation of remote Object.

— Class factory creates instance of COM Class which having CLSID & SCM return pointer to interface of Object.14

Page 15: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM Architecture

— The Middle layer consist of Remoting Architecture. It takes care of sending data across different address spaces using Marshalling & unmarshalling.Marshalling packs the parameter in to standard format at clients address space while Unmarshalling unpacks standard format to appropriate data Unmarshalling unpacks standard format to appropriate data representation.

15

Page 16: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM Architecture— The Bottom layer is a wire protocol Architecture which further

extends the Remoting architecture to work across different machines.

— DCOM wire protocol is based on DCE-RPC Specification it also clear garbage collection of remote object reference when client abnormally terminates.

— When server is started by Server side SCM (DCOM SCM is a — When server is started by Server side SCM (DCOM SCM is a DCOM interface to Service Control manager which allows Controlling of services like Starting/Stopping Services on windows system) its assigned an object exporter identifier(OXID).

16

Page 17: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

DCOM Architecture

— An object reference is created to represent the interface pointer. it contains IID,OXID & address of OXID Resolver. The client side OXID resolver check if it has mapping of OXIS If not then it get registered in RPC binding & return it to object proxy.

— It enables connection between Object Proxy & Interface proxy.

17

Page 18: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM INTERFACE & IDL— COM provide interface definition language (IDL) which is

used to define interfaces.— COM IDL is based on DCE IDL.— The COM interface can be viewed in two perspective— A logical perspective focuses on the interface method &

operation they perform.— A physical perspective focuses on memory,Netword packets & — A physical perspective focuses on memory,Netword packets &

runtime environment.— IDL provide Both Network & Location transparency &

Programming Language Independence.

18

Page 19: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM IDL— The file that contains interface & type librrary definition is

called IDL file & has as .idl extension .— It contain one or more interface definitions.— It is defined by keyword interface & parsed by Microsoft

Interface Definition Language(MIDL) Compiler.— IDL has four components— Interface name— Interface name— Base interface name — Interface body— Interface attributes -: Specifies characteristics of interfaces &

of data & methods within the interface it enclosed in square brackets.

19

Page 20: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM INTERFACS

— COM SUPPORTS THREE STANDARD INTERFACES

— 1) IUnknown Interface

— 2) Idispatch Interface

— 3) IClassFactory Interface

20

Page 21: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

1) IUnknown interface— All COM objects support an interface called IUknown— This interface provides control of objects lifetime through

IUknown:AddRef & IUknown:Release methods & ability to retrieve other interfaces implemented by objects through IUknown:QueryInterface method.

— IUknown:AddRef & IUknown:Release methods &IUknown:Release methods maintain objects reference count.IUknown:Release methods maintain objects reference count.

— When first object is created then reference count is set to one & Function used in interface must call IUknown:AddRefthrough the pointer to increment reference Count.

— Before pointer can be destroyed IUknown:Release method is called. After reference count reaches to 0 the object is destroyed & all interfaces to it become invalid.

21

Page 22: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

IUnknown interface— The IUknown:QueryInterface method determines whether or

not an object supports specific interface.— If an object supports an interface ,the QueryInterface returns a

pointer to that interface.

22

Page 23: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Idispatch Interface— IDispatch is a standard interface that expose the functionality

of Application programmatically.— Idispatch interface exposes object, methods & properties to

application that support automation.— It has proxy & stub to take care of marshalling & each method

in a interface is identified by DISPID.— It uses CoCreateInstance function to initialize ActiveX or — It uses CoCreateInstance function to initialize ActiveX or

OLE.— Components using Idispatch can be accessed by following

method— 1)Late binding -: here client fetches DISPID by invoking

GetIDsOfNames.its advantage is it do not need type library. but it is less flexible.

23

Page 24: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Idispatch Interface— 2) Early Binding -: In this method compiler consult the typelib

to obtain DISPID so that the client can make single call using invoke method.

24

Page 25: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

IClassFactory Interface— A COM class object normally implement IClassFactory

interface & thus referred to as class factories.— CoCreateInstance() function enable client to instantiate class

which calls IClassFactory internally.— The IClassFactory interface contains two methods — The first method CreateInstance creates uninitialized object of

specified CLSID.specified CLSID.— The second method LockServer,locks the objects server in

memory ,keeping the component Open in memory & allowing object to be created more quickly.

25

Page 26: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM Threading Model— Initially COM had no support for Multi-threading but when

Threading model was included in windows COM extended to include threading. its used to enhance performance of application

— COM has basically 2 types of threading models— 1)Threading Model for User-driven GUI applications

it synchronized with message queue.it synchronized with message queue.— 2)Threading Model for Worker components

its needed to improve performance of the system.A thread is a path of execution through process which enables an

application to perform functions concurrently.

26

Page 27: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COM Threading Model— Microsoft has defined different levels of thread safety using

threading model. (i.e. safety of shared data used by 2 processes simultaneously)

— The basic unit of thread safety in COM is called apartment— There are three types of apartments— 1) Single-threaded Apartment (STA)— 2)Multi-threaded Apartment (MTA)— 2)Multi-threaded Apartment (MTA)— 3)Rental-threaded Apartment (RTA)

27

Page 28: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

— It has only one thread executing per apartment— Here method call automatically synchronized & dispatched

using Microsoft message queuing(MSMQ).— This components are accessible through STA only— Call from other client is marshaled by COM to main STA & is

received by proxy in one apartment & send to stub in another.— To improve system components can be accessed through main

1) Single-threaded Apartment (STA)

— To improve system components can be accessed through main STA.

28

Page 29: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

— It has More than one thread executing per apartment— Here method calls are not synchronized automatically Special

synchronization mechanism used for this purpose.— This components supporting this model call it from any thread — If object is present in MTA & client call through STA then

marshalling is needed.

2) Multi-threaded Apartment (MTA)

29

Page 30: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

— It allows More than one thread to enter an apartment.— When thread enters an apartment it requires an Apartment

wise lock that prevent other threads from entering Apartment.— Its released when thread exits the Apartment.— Its more efficient & flexible than STA because it does not start

with single thread.

3) Rental-threaded Apartment (RTA)

30

Page 31: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Single threading Model— The object receives only client request at a time.— As single process can have several threads that are employed

to facilitates the concurrent use of COM objects— The windows messaging queue is used to synchronize &

dispatch COM method calls to objects. Message queue synchronize calls serially.

— When 2 clients want to access same object they uses following — When 2 clients want to access same object they uses following sequence of steps

— 1)first client creates Objects— 2)second client call is queued in MSMQ until first client — complete his work— 3) Second client will connected to same object when no

other client calls are in queue31

Page 32: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

APARTMENT THREADING MODEL— Apartment is a logical container that creates association

between Objects & threads.— Every object is associated with one & only one Apartment.— Its more than just Logical construct, their rues describes

behavior of COM System.— This model is used in object with visual control, batch

processing & object active over long time.processing & object active over long time.— This model improves systems performance.— Its used for stateful data application

32

Page 33: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

FREE THREADING MODEL— In this model multiple clients concurrently executes an object

method from different threads.— In this model interface do not need to marshaled between the

apartments.— All client threads running STA/MTA can call objects directly

instead of going through proxy.— Its used for stateless data application— Its used for stateless data application

33

Page 34: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

NEUTRAL THREADING MODEL— It’s a variation of FTM — Multiple client can call the objects on diffeent threads at the

same time.— COM ensures that no two calls conflicts.— If free objects are present COM allocate them to clients— This Model is Available in only COM+— Its used in high load stateless data applications.— Its used in high load stateless data applications.

34

Page 35: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Marshalling— The issue of passing parameters in DCOM is major area of

concern .— Marshaling is a process of packaging method call & their

parameters into a packet & transmitting them over the network.

— COM Offers three types of Marshalling.— 1)Standard Marshalling— 1)Standard Marshalling— 2)Custom Marshalling— 3)Type Library Marshalling

35

Page 36: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Types Of Marshalling

36

Relation Between Types Of Marshalling

Page 37: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Custom Marshalling— It’s a fundamental Marshalling mechanism in COM & this

method allows the client to gain a complete control over marshalling process.

— As it is difficult to implement & is more generic Standard marshalling mechanism is used

— In custom marshalling COM has no support for transmission of data between proxy & stub.of data between proxy & stub.

— Marshalling interface is dine by loading the proxy DLL in clients address space however no stub DLL is created.

— Custom marshalling is used in situations to generate customized proxy to improve speed of transmission, reduce network traffic,improve security.

— It is used in Image processing applications to improve the speed of multimedia file transmission by compressing code.37

Page 38: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Custom Marshalling— It is also used to communicate between intra-process

components.— Custom marshalling makes use of Imarshal interface it

marshals interface pointer into stream object & back.— It has following Functionalities— 1) Marshall Interface— 2) UnMarshall Interface— 2) UnMarshall Interface— 3) Release Marshal Data— 4) Disconnect Object.— 5) Get UnMarshall Class— 6) Get Marshall Size Max

38

Page 39: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Standard Marshalling— It is used when object does not implement marshalling but

generates it using user defined interface for the object.— In standard marshalling COM generic proxy & stub

communicate using RPCs.— These custom interfaces are compiled by MIDL Compiler to

generate Standard marshalling code.— MIDL generate following files— MIDL generate following files— 1)A Header file — 2)A file containing definition for IID & CLSID.— 3) A file containing Marshalling code— 4)A type Library file— These files are compiled & linked to produce the stub/proxy

DLL to marshal the interface.39

Page 40: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Standard Marshalling— The stub/proxy must be registered & SCM loads the required

proxy on the basis of IID returned to the client.— The standard marshalling has four interfaces— 1) IRpcfactoryBuffer that is used to instantiateIRpcProxyBuffer in the server— 2) IRpcProxyBuffer used to connect STUB.— 3) IRpcStubBuffer has invoke method to instantiate stub.— 3) IRpcStubBuffer has invoke method to instantiate stub.— 4) IRpcChannelBuffer used for communicate between Stub &

Proxy.

40

Page 41: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Standard Marshalling

41

Page 42: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

Type library Marshalling— It uses IDispatch marshaller.

— COM has efficient as marshalling code generated.

— It is generic it is not as efficient as marshalling code generated.

— It took more time for lookup & more time is consumed but its more flexible & easy to use

— No proxy/stub is needed to build & registered.

— It is available in windows.— It is available in windows.

Handler Marshalling— Its between standard & custom marshalling

— Its useful for objects that perform work in clients address space, making remote call only when needed.

— It supports IStdMarshallInfo that retrieve CLSID of handler object to be loaded into clients address space.

42

Page 43: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Architecture

43

Page 44: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Architecture— The architecture of .NET is tired, Modular & hierarchical.

Each tier of .NET framework is a layer of Abstraction.— The .NET languages(most abstracted) are the top tier while

CLR(least abstracted) is a bottom tier.— .NET framework is partitioned into separate modules, each

having its own responsibility.The Components of .NET Framework is described as followsThe Components of .NET Framework is described as follows1) Common Language Runtime (CLR)

CLR monitors the execution of .NET applications &provides essential services. It manages code at executiontime & provide Core services like remote communication,memory management & thread management.

CLR is .NET equivalent of JVM it’s the runtime that convertsMSIL code to host machine language code that is executable44

Page 45: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Architecture2) Standard System Services

Standard services like ADO.NET & XML are madeuniversally available & standardize across language bybringing them under Control of .NET framework

3)User & Program interfaceIt includes windows forms & web forms that provide userinterface for windows & web applications. It contain webinterface for windows & web applications. It contain webservices which provide a mechanism to communicate overinternet using SOAP which is analogous to ORPC in DCOM.

4) The .NET framework class library (FCL)It is a set of managed classes that provide access to systemservices. it is comprehensive & object oriented collection ofreusable types that can be used to develope UI/non UI webapplications.45

Page 46: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Architecture— Remoting,xml,sockets,file i/o,database access comes under

FCL.— ITS hard to avoid FCL & this improves portability & security

of applications. Base Class Library (BCL) is subset of FCL & has core set of classes that serve as API of CLR.

— 5) Common type systems (CTS)— It specifies rules related to data types that languages must — It specifies rules related to data types that languages must

follows. as all programs are converted to standard intermediate language (MSIL) their datatypes must be converted to standard datatypes. CLS is a subset of CTS.

— The .NET types are separated in to value & reference type value are primitive types inherit from system. The lifetime of reference type is controlled by garbage collector.

46

Page 47: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Architecture— 6)Common Language Specification— It’s a set of specifications or guidelines defining a .NET

language. Shared specifications promote language interoperablity.CLS defines common type of managed languages, which is subset of CTS.

47

Page 48: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Remoting— .NET Remoting is used instead of DCOM because— DCOM relies on ORPC Protocol that does not support object

model which prevents interoperability across platform.— DCOM communicate using ports that are blocked by firewall— .NET Remoting eliminate the difficulties of DCOM by

supporting transport protocol format & Communication protocol.protocol.

— Web Services Vs .NET Remoting— 1)web services can only be accessed through HTTP while

.NET Remoting can use across any protocol.— 2)Web Services works in stateless environment whereas .NET

Remoting supports state management.— 3)Web services relies on SOAP while .NET Remoting Relies

on CLR Assembler.48

Page 49: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Remoting

Client object

Server object

Proxy

49

Remoting System Remoting SystemChannel

Remoting Process

Page 50: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Remoting— .NET Remoting allows an application to make an object

available across Remoting boundaries.— The Steps in .NET Remoting Process is as follows— 1) .NET Remoting makes remote object available to client

through activation URL.— 2)The client Creates a new instance of server class & uses it

like a local object.like a local object.— 3)The Remoting System creates a proxy object that represent

the class & return to the client object a reference to the proxy.The proxy does not implement the remote objects functionality but provide interface to it.

— 4) When client calls a method the remoting infrastructure handles the call, check the type information & send call over the channel to server process.50

Page 51: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

.NET Remoting— 5) A listening channel picks up the request & forward it to

server Remoting system, which locate & calls the requested object.

— The process is reversed as server Remoting system bundles response to message that the server channel send to client channel & Finally client Remoting system return the result of call to client object through proxy.call to client object through proxy.

51

Page 52: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

COMPARISON BETWEEN CORBA,DCOM & RMI

52

Page 53: CHAPTER 7 COM and .NET.ppt - Bhushan Jadhavbhushanjadhav.webs.com/Notes and PPTs/CHAPTER 7 COM... · CHAPTER 7 COM and .NET — Evolution of DCOM — Introduction to COM — COM clients

53