outline - uio

34
NET CLR NET REMOTING COM COM .NET CLR,.NET REMOTING, COM, COM+ INF5040 Kim Mathiassen Anh Tuan Nguyen and Anthe Rugstad Kim Mathiassen, Anh Tuan Nguyen and Anthe Rugstad

Upload: others

Post on 26-Oct-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Outline - UiO

NET CLR   NET REMOTING  COM  COM.NET CLR, .NET REMOTING, COM, COM+INF5040

Kim Mathiassen  Anh Tuan Nguyen and Anthe RugstadKim Mathiassen, Anh Tuan Nguyen and Anthe Rugstad

Page 2: Outline - UiO

OutlineIntroduction to .Net FrameworkNET   .NET component conceptCLR (Common Language Runtime).NET RemotingCOM, COM+ and DCOM

.NET Remoting vs DCOMCase studyy

The assignment done in .NET Remoting

2

Page 3: Outline - UiO

Introduction to .Net FrameworkA Microsoft approach to ”component software”C iComprises

Common Language Runtime (CLR)l b f ll f d ll lA large number of partially interfaced, partially class‐

based frameworks packaged into assembliesA  b   f t l   A number of tools  

3

Page 4: Outline - UiO

.NET component concept (1/2)p p ( / )Assemlies

The units of deployment  versioning  and managementThe units of deployment, versioning, and managementin .Net

A set of files in a directory hierarchy (equivalent to thecontents of a JAR file)

( )Manifest: a table of contents (Metadata)Modules

code is expressed in CIL (Common Intermediate Language): code is expressed in CIL (Common Intermediate Language): MSILResources immutable data

R  Resources 

4

Page 5: Outline - UiO

.NET component concept (2/2)p p ( / )An assembly

private to a single application or shared among multiple private to a single application or shared among multiple applications.

Name resolution schemeStrong name = (publisher token, assembly name, versionvector, culture)

Publisher token: the SHA‐1 hash of the public half of a public/private key pair.Version vector = (major, minor, build, patch)( j , , , p )

Signed by encrypting an MD‐5 has over the entire assemblyi th i t  kusing the private key.

5

Page 6: Outline - UiO

.NET CLR (1/5)( / )Common Language Infrastructure (CLI)

A l t l  l tfA language‐neutral platform

C iComprisesThe specification of execution engine services (loader, JIT compiler  and garbage‐collecting memory manager)compiler, and garbage collecting memory manager)The common type system (CTS)The common language specification (CLS)g g p ( )

6

Page 7: Outline - UiO

.NET CLR (2/5)( / ).NET CLI: CTS

The superset of many languages’ core concepts in the type space‐> CLI‐compliant code can operate over the entire CTS space‐> for code implemented in different languages to interoperate.

.NET CLI: CLSA strict CTS subset constructed in such a way that a wide variety oflanguages can cover it completelylanguages can cover it completely‐> if a definition is CLS‐compliant, then any language classified as a CLS consumer will be able to make use of that definition.A language can also introduce new definitions in the CLS spaceA language can also introduce new definitions in the CLS space(CLS producer)A language can extend existing definitions in the CLS space (CLS extender)

7

Page 8: Outline - UiO

.NET CLR (3/5)( / )

T l l CTS t  Top‐level CTS type hierarchy

8

Page 9: Outline - UiO

.NET CLR (4/5)( / )Common Language Runtime

The Microsoft implementation of the Common Languagep g gInfrastructure (CLI)

Includes support for COM and platform interoperationIncludes support for COM and platform interoperation

Offers dynamic loading and unloading, garbage collection, t t i t ti   t d t fl ti   ti  context interception, metadata reflection, remoting, 

persistence and other runtime services that are fully languageindependent

Microsoft supports different languages on CLR: C#, Jscript, Managed C++, and Visual Basic.Net, J#, ….

9

Page 10: Outline - UiO

.NET CLR (5/5)( / )

10

Page 11: Outline - UiO

.NET Remoting Architecture (1/10)g ( / )The .Net remoting infrastructure is an abstract approach to inter‐process communication.

Objects can be passed by value, or copied.

Objects are automatically passed beween applications in different application domains or on different computers pp pusing different transportation protocols, serializationformats, object lifetime schemes and modes of objectcreation.

Remoting makes it possible to intervene in almost anyt   f th i tistage of the communication process.

11

Page 12: Outline - UiO

.NET Remoting Architecture (2/10)g ( / )Copies

S   bj t     i d t   li t Server objects are copied to client process

   R f… vs. ReferencesMany objects can not or should not be copied and moved e.g. extremely large objects  > a reference to the server object is extremely large objects ‐> a reference to the server object is passed to the client.Clients collects all information (the call, arguments, return values or exceptions) about the call and send it to the server process; then, the correct server object is located

12

Page 13: Outline - UiO

.NET Remoting Architecture (3/10)g ( / )Using object references to communicate between server objects and clients the the heart of remotingserver objects and clients the the heart of remoting

13

Page 14: Outline - UiO

.NET Remoting Architecture (4/10)g ( / )Messages: objects that implement IMessage interfaceProxies

Transparent proxyA dynamically created block of code existing in the client applicationdomain (context) on behalf of the remote object and exposes all ofdomain (context) on behalf of the remote object and exposes all ofits features: all fields, properties, events, delegates and methodsInstance of System.Runtime.Remoting.Proxies.__TransparentProxy.

Real proxyInstance of a class inheriting from the abstract base class RealProxydefined in System.Runtime.Remotingy gThe transport layer for transparent proxiesIs able to dynamically create a transparent proxy for any arbitray.NET class‐type.

14

Page 15: Outline - UiO

.NET Remoting Architecture (5/10)g ( / )Channels

Responsible for transporting messages (endpoint‐to‐endpoint communication)

An abstract of a specific transport protocol and wrap the protocol to make it available to the .NET Remoting infrastructure

TCP channel or HTTP channel

The channel model is extensible: build your own channel (APPC, IPX, or Windows Named Pipes)Windows Named Pipes)

Implements IChannelReceiver implements IChannelSender

System.Runtime.Remoting.ChannelServices: manage and register .NET Remoting channels.

15

Page 16: Outline - UiO

.NET Remoting Architecture (6/10)g ( / )Sinks

A pluggable component provided to the channel through a channeli k  id   lsink provider class.

Sink providers: IClientChannelSinkProvider & IS Ch lSi kP idIServerChannelSinkProvider

Sinks: IClientChannelSink & IServerChannelSink

Interception, security checks, logging or whatever you want to control or monitor regarding Remoting traffic

IClientFormatterSinkProvider (IClientFormatterSink) & IServerFormatterSinkProvider (IServerFormatterSink)

16

Page 17: Outline - UiO

.NET Remoting Architecture (7/10)g ( / )Dispatcher

The proxy’s counterpart at teh receiving end of thep y p gcommunication.

StackBuilderSink class in StackBuilderSink class in System.Runtime.Remoting.Messaging namespace

T kTasksReceives messagesBuilds the stack‐frameI k   h dInvokes a methodCollects resultsAnd creates a response message

17

Page 18: Outline - UiO

.NET Remoting Architecture (8/10)g ( / )

18

Page 19: Outline - UiO

.NET Remoting Architecture (9/10)g ( / )

19

Page 20: Outline - UiO

.NET Remoting Architecture (10/10)g ( / )The Call context

S t R ti R ti M iSystem.Runtime.Remoting.MessagingCallContext.SetData(), CallContext.GetData()IL i lTh dAffi iILogicalThreadAffinative

Remoting servicesSystem.Runtime.RemotingConnect() of RemotingServices class

Provides low‐level access to RemotingR d  i d  bjReturned proxied object

20

Page 21: Outline - UiO

Component Object Model (COM) (1/2)Component Object Model (COM) ( / )Platform independent, distributed, object‐based systemsystemFoundation technology for Microsoft OLE and ActiveXD i d  i il  f  C   d Mi f  Vi l B iDesigned primarily for C++ and Microsoft Visual BasicIs supported in Vista

21

Page 22: Outline - UiO

COM (2/2)( / )Binary standardL    b   bl         f  iLanguage must be able to create structures of pointersUses interfaces in a Java like fashion

22

Page 23: Outline - UiO

COM+Primarily for Microsoft Visual C++ and Microsoft Visual BasicVisual BasicBuilds on and extends COM

Th d  ll iThread allocationSecurityT i     i h Mi f  T i  STransaction support with Microsoft Transaction Server

23

Page 24: Outline - UiO

DCOM

24

Page 25: Outline - UiO

.Net and COM.Net provides transparent integration with COMOld COM  li i    b   d  i h    N  Old COM applications can be used with new .Net applications

25

Page 26: Outline - UiO

.Net Remoting vs DCOMg.Net Remoting  DCOM

dUses TCP or SOAPUses HTTP protocol 

Based on RPCNot firewall friendly, cannot choose port

Supports cross‐platformEasy deployment through 

choose portOnly Windows‐basedComplex deployment in Easy deployment through 

XML or programmaticallySecurity depends on the host 

Complex deployment in Windows registriesDepends on Windows 

of the .Net Remoting Object security

26

Page 27: Outline - UiO

.Net vs DCOM.Net Remoting  DCOM

l ll f l f h h d bClient request will fail if the remoting server is not already started, and if the remoting 

The COM server is started by Service Control Manager upon receiving the activation started, and if the remoting 

component is not hosted in Internet Information Server

upon receiving the activation request from the client

27

Page 28: Outline - UiO

Demo

28

Page 29: Outline - UiO

Server codestatic void Main(string[] args){

TcpChannel chan = new TcpChannel(8085);TcpChannel chan new TcpChannel(8085);ChannelServices.RegisterChannel(chan, false);RemotingConfiguration.ApplicationName =

"EBankingServer";"EBankingServer";

RemotingConfiguration.RegisterActivatedServiceType(i jtypeof(ebankingObject.Account));

System.Console.WriteLine("Hit <enter> to exit...");System.Console.ReadLine();ChannelServices.UnregisterChannel(chan);

}}

29

Page 30: Outline - UiO

Client configuration codegTcpChannel chan = new TcpChannel();ChannelServices RegisterChannel(chan false);ChannelServices.RegisterChannel(chan, false);RemotingConfiguration.RegisterActivatedClientType(

typeof(ebankingObject.Account)," //l lh 8085/ ki S ")"tcp://localhost:8085/EBankingServer");

30

Page 31: Outline - UiO

Client codeebankingObject.Account obj =

new ebankingObject.Account();

obj.Create(ammount);

ebankingObject.Account obj = new ebankingObject.Account(accountId);

account.SucessfullTransfer(toAccount, amount);account.UnsucessfullTransferWT(toAccount, amount);account UnsucessfullTransferWoT(toAccount amount);account.UnsucessfullTransferWoT(toAccount, amount);

31

Page 32: Outline - UiO

Distributed objectjpublic class Account : MarshalByRefObject{{

……

}}

32

Page 33: Outline - UiO

References"Component Software: Beyond object‐oriented programming" by Clemens Szyperski et.al, 2002, (ISBN 0‐201‐74572‐0)Handling Language Interoperability with the Microsoft .NET Framework. http://msdn.microsoft.com/en‐us/library/ms973862 aspxus/library/ms973862.aspx.Net Framework Remoting Architecture. http://msdn.microsoft.com/en‐us/library/2e7z38xb.aspxp // / / y/ 7 3 pRemoting Architecture in .Net. http://www.codeproject.com/KB/IP/Remoting_Architecture.aspx

33

Page 34: Outline - UiO

ReferencesComparison of DCOM and Dot Net Remoting http://wwwericsson com/mobilityworld/sRemoting http://www.ericsson.com/mobilityworld/sub/open/technologies/open_development_tips/docs/odt compare dcomodt_compare_dcomComponent Development – MSDN http://msdn microsoft com/en‐http://msdn.microsoft.com/enus/library/aa139693.aspxDCOM Architecture – MSDN DCOM Architecture – MSDN http://msdn.microsoft.com/en‐us/library/ms809311.aspxus/library/ms809311.aspx

34