dot.net assembly programing - a brief introduction

Upload: apextgi

Post on 03-Jun-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    1/15

    Assembly

    facebook.com/apex.tgi

    twitter.com/ApextgiNoida

    pinterest.com/apextgi

    https://www.facebook.com/apex.tgihttps://twitter.com/ApextgiNoidahttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttps://twitter.com/ApextgiNoidahttps://twitter.com/ApextgiNoidahttps://www.facebook.com/apex.tgi
  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    2/15

    Versioning Problem(DLL Hell)

    DLL Hell refers to te set of problems ca!sed wen m!ltiple applications attempt to sare a common component like a librar" (DLL) or a $omponent %b&ect 'odel ($%') class.

    n te most t"pical case one application will install a new *ersion of te sared component tat is not backward compat*ersion alread" on te macine.

    Alto!g te application tat as &!st been installed works +ne existing applications tat depended on a pre*io!s *ersiocomponent migt no longer work.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    3/15

    Versioning Problem(DLL Hell) contin!e,

    -o sol*e tis *ersioning problem.Netintrod!ce te concept ofASSEMBLY.

    Assembl" simpli+es te deplo"ment iss!e.

    .Netsol*e tis *ersioning problem b" making te dierent dierent *ersion of an assembl".

    Now te existing applications tat depended on a pre*io!s *ersion of te sared component also work.

    n man" wa"s an assembl" is e0!al to a DLL in toda"1sworld.Assembliesare a 2logical DLLs.2

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    4/15

    3at is an assembl"4

    An assembl" is a complied +le wic consist of all te information wic is re0!ired for te $L5 to deplo" te application

    Assembl" is also known as P7(Portable 7xec!table +le).

    3en te so!rce code of an" lang!age of.Netiscompiledrespecti*ecompiler comes into pict!re.

    8!st after compilation compiler generates a +le.

    -is +le is called assembl".

    Assembl" can be in te form ofEXEorDLL.

    f te so!rces code asMain()f!nctiontenafter compilation exe will be generated.

    f te so!rces code as notMain()f!nctiontenafter compilation dllwill be generated.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    5/15

    Part of an Assembl"

    An assembl" consist of fo!r part.

    Manifest9 'anifest explain te *ersioning information and sec!rit" polic".

    Meta Data9 'eta data explain te str!ct!re of a class or t"pe of te class.

    IL9 L refers to ntermediate Lang!age. t is te code independent to %: or $P6 beca!se tis code is in s"mbolic code or code wic is onl" !nderstandable b" $L5.

    Resouce:t consist of te information of an" image like pat.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    6/15

    ;inds %f An Assembl"

    -ere are fo!r t"pes of Assembl"#

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    7/15

    Pri*ate Assembl"

    A pri*ate assembl" is an assembl" tat is deplo"ed wit an application and is a*ailable for te excl!si*e !s

    -at is oter applications do not sare te pri*ate assembl".

    " defa!lt wen te so!rce code is compiled te compiler generates te Pri*ate assembl".

    Pri*ate assembl" does not a*e te sec!rit" polic".

    f an application wants to access te static assembl" it m!st be located on te same folder in wic pri*atlocated.

    :ec!rit" polic" of $L5 pre*ents te access to assemblies kept in dierent#dierent folder.

    Pri*ate assembl" does not a*e ABA(A!tentication andA!torisation)

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    8/15

    :ared Assembl"

    A sared assembl" is an assembl" a*ailable for !se b" m!ltiple applications on te comp!ter.

    :ared assembl" contains te sec!rit" information wic is re0!ired for te $L5.

    :ared assembl" can be access b" te application wic is not kept in te same folder in wic assembl" is resided.

    -o !se a sared assembl" it is re0!ired to map te assembl" in >lobal Assembl" $ace.

    Assemblies sipped witmicrosoft*is!al st!dio.net are sared assemblies.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    9/15

    D"namic Assembl"

    D"namic assemblies are tose assemblies wic is created at 5!n -ime.

    -e System.Reection.Emit namespace is !sed for crating te d"namic assembl".

    -e System.Reection.Emit namespace contains classes tat allow a compiler or tool to emit metadata and 'lang!age (':L) and optionall" generate a P7 +le on disk.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    10/15

    :ataliteAssembl"

    A .N7- Cramework assembl" containing reso!rces speci+c to a gi*en lang!age.

    6sing satellite assemblies "o! can place te reso!rces for dierent lang!ages in dierent assembli

    -e correct assembl" is loaded into memor" onl" if te !ser elects to *iew te application in tat lan

    :atellite assemblies gi*e tis exibilit"

    Eo! create an" simple text +le wit translated strings create reso!rces and p!t tem into tebin!

    -at1s it. -e next time "o!r code will read te $!rrent $!lt!re propert" of te c!rrent tread and aappropriate reso!rce.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    11/15

    'aking an Assembl"

    !sing :"stemF

    namespacem"pro&

    G

    P!blic class emplo"ee

    G

    p!blic string sow()

    G

    ret!rn 2doing practice of assembl"2F

    DLL ne*er contains teMain()f!nction.

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    12/15

    'aking an Assembl" contin!e..

    Now sa*e te +le wit te namespaceIs name as#

    My#$o%.cs

    Nowcomilete +le like tis#

    csc&t:lib$a$ymy#$o%.cs

    Now a +le is generated namedmy#$o%.!ll

    -is +le is known as assembl".

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    13/15

    6sing an assembl"

    -o !se an assembl" te reference m!st be added in te program likeusin"my#$o%'

    Eam#le

    !sing :"stemF

    !singm"pro&F

    classceck9emplo"ee

    G

    p!blic static *oid 'ain()

    G

    ceck cJnew ceck()F

    string sJc.sow()F

    $onsole.3riteLine(s)F

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    14/15

    6sing an assembl",

    Now sa*e te +le in te same folder in wicmy#$o%.!llis kept.

    :a*e asc*ec+.cs

    Now compile te program like tis#

    csc&$:my#$o%.!llc*ec+.cs

    Now 5!n te Program .

    ,ut#ut#

    -doing practice of assembl"

  • 8/12/2019 DOT.net Assembly Programing - A Brief Introduction

    15/15

    -ank Eo!

    A#e /0 In!ia

    E12 3 Secto$ 453 6o

    2712 8 921222&219&2

    =7;5;>9;9

    Email i!: #$ata#?a#eStay connecte! @it* us fo$ mo$e *a#te$son .6E/

    ttp9//www.apextgi.in

    http://www.apextgi.in/DotNet/AboutDotNet.aspxhttp://www.apextgi.in/DotNet/AboutDotNet.aspx