Page 1 :
jet Assemblies and Web Forms, , iN 5.1, , , , NET ASSEMBLIES 3, AND WEB FORMS, , aT TT a Rd OE Ia TE EE", , , , , , , , (April/May 2012, March/April 2013), 4 programmer writes in a high-level language that implements, Cture (for example, the fields or properties of the class) and, r methods can be static functions, The compilation of the program, produces a file called an assembly that contains the compiled code in the Microsoft, , intermediate language (MSIL), and a manifest that contains all references to dependent, assemblies., , In the NET Framework,, a class defining its stru, methods. Some of these r, , Assemblies are a vital element in the architecture of the CLR. They are the units of, packaging, deployment, and versioning of application code in the .NET Framework., Using assemblies, one can deploy application code inside the database and provide a, uniform way to administer, back up, and restore complete database applications., , The assembly manifest contains metadata about the assembly, describing all of the, structures, fields, properties, classes, inheritance relationships, functions, and methods, defined in the program. The manifest establishes the assembly identity, specifies the, files that make up the assembly implementation, specifies the types and resources that, make up the assembly, itemizes the compile-time dependencies on other assemblies., and specifies the set of permissions required for the assembly to run properly. This, information is used at run time to resolve references, enforce version binding policy,, and validate the integrity of loaded assemblies., , The .NET Framework supports cust 1 ing classes,, functions, and methods with additi, metadata. All .NET Framework, interpretation and store them as ass, in the same way as any other me, , , , Scanned with CamScanner
Page 2 :
v, , , , code, ted Code 1 sion, , , , the compl, , , , aint, , , , basicall), , , , , , , , , ; as can k applica ,, , ‘Assemblies are assemblies ca” rramewor th, , a a TA ° coping, and ¢ ., , Intermediate Lan Ts uilding blocks of MN use, activation SCOF oes Security, 5 e the . ssources that are buj, , Sol deployment, and resources uilt to Work, , fundamental unit ©} te é ly provides the common ‘anguage, , ssembl) / ;, permissions. An assem tof functionality of type implementations. To the TUntim, pware OF TY ,, , ogical uni, and forma logical « to be a, , fan assembly, semblies, , jon it nee, side the context of, , , , together, , runtime with, , a type does not exist ou 4 Private As, 5.2.1 Differences Between Shared an, , assembly thi, s jvateasserbly 5 ences outside the scope of the, Ne eek ot, And cannot be reference older, ere they are ke], applications where they, , loblly/shared across the machine al the applicatcts, Te ly cache(Gag), one needs to register the assembly with 2 Ste ith .Net framework installed, , sutil.exe. GAC can be found on all the comp :, ai 4 single application is called as private assembly, Suppose a DLL is created, which encapsulates the business | - ee <a will, used by the client application only and not by any other app! sorine In Be jer to run the, application properly the DLL must reside in the same folder in which the client application, , is installed. Thus the assembly is private to the appl, , , , inform:, , , , is available to Particula,, , , , bly: A pr, , , , , , , , where th, , , , , , The assembly which is used only by, , , , , , Suppose that a general purpose DLL is created, which provides ity which will be, used by variety of applications, then, instead of each client application having its own copy, of DLL one can place the DLL in ‘global assembly cache’, Such assemblies are called as, , shared assemblies, NG SHARED ASSEM|, , A shared assembly is one that is used by multiple applications on the machine. A shared, assembly must have a name that is globally unique. The NET Framework supports these, , , , , , , , naming requirements through a technique called strong names., , Shared assemblies must have a "strong name” consisting of the name of the assembly, the, , Nersion, & 64 bit hash of a public key (called a ‘token') and the culture., , Following steps are involved in creating share, * Create the DLL/EXE source code, , ., , d assemblies :, , Generate unique assembly name y ing SN, * Sign the DLU/EXE with the, * Compile the DLL/EXE, , utility |, , Private key by modifying Assemblylnfo file, , , , , , Place the result,, fant DLL/EXE jn global assembly cache using AL utility, , , , N, , 5, , 5, , , , , , , , Jies and Web Forms, a assemb : eS as a 5.3, , $ TE., A while objects are very powerful and usefy ue, , ariables. functions, or routines that do use!, va, , , , , , ca ‘ful work - without the need for an actual object, instance, , iia shared Methods, , in VB.NET, there are methods that are available wi, , These are know, class methods in other languages,, , , , A shared method is not accessed via an object instance like a regular method, but rather i, accessed directly from the class. The following is a simple example of a shared method:, , public Class Math, , shared Function Add (ByVal a As Integer, ByVal b Ag Integer) ag Integer, Return a +b, end Function, End Class, One can use this method - without instantiating a Math object - as follows:, Dim result As Integer, result = Math.Add(5, 10), , Rather than using an object variable, one can use the actual class name to reference the, method. With a normal method this would result in a syntax error, but with a shared method, this is perfectly acceptable., , Shared methods can also be accessed via objects just like regular methods, but their most, common use is to provide functionality without the requirement for creating an object. In, fact, when a shared method is invoked, no object is created - the method is called directly,, much like a procedure in a Module. Shared methods can also be overloaded just like regular, methods, so it is quite possible to create a set of variations on the same shared method,, , each having a different parameter list., , The default scope for a shared method is Public. It is possible to restrict the scope of a, shared method to Friend, Protected, or Private by prefixing the declaration with the appropriate, Scope., , A good example of how shared methods are used comes from the .NET system class, , libraries, When one wants to open, File clas:, , , , Scanned with CamScanner
Page 4 :
aaa, , (Chapter-5}———__________, , -Net Progratnmin, 8, , t, o sions ofa componen', , Side-by-side execution of two ve, , , , App C, , , , Comp v2.0, , Fig. 5.2, , over which versions of a component an, , Side-by-side execution gives you more control i D :, jon of the runtime an application, , application binds to, and more control over which vers!, uses., 5.6.1 Benefits of Side-by-Side Execution, Prior to Microsoft Windows XP and the NET Framework, DLL conflicts occurred because, applications were unable to distinguish between incompal ble versions of the same code., Type information contained in a DLL was bound only to a file name. An application had no, way of knowing if the types contained in a DLL were the same types that the application, was built with. Aé a result, a new version of a component could overwrite an older version, and break applications., Side-by-side execution and the NET Framework provide the following features to eliminate, DLL conflicts:, * Strong-named assemblies,, Side-by-side execution uses strong-named assemblies to bind type information to a specific, version of an assembly. This prevents an application or component from binding to an, invalid version of an assembly., * Version-aware code storage,, The .NET Framework provi i 4, provides version-aware code Storage in the global assembly cache |, , TH ve eee ro ¥ pies code cache present on all computers wit, 2 |. It stores i i i, information, and supports multiple San based on version, culture, and publishel, , , , , , of components and applications., , , , Assemblies ana web Forms, te ya eee pe), i ation., , Jsolal 5.7, , ’, , ing .NET Framew, using the ork, one, jcolation, an essential component st Create applications and cor, Ses esourcentyae enna Of side-by-side ecgis mponents that execute in, of ther ae sed and sharing resources with n. Isolation involves being aware, of an application or component. Isolation aj Confidence among multiple versions, , way:, » Version Compatibility, , versions of the .NET Framework are treated as a si, its associated .NET Framework assemblies (a eo;, , i : a ncept referred to as ificati, One can redirect assembly binding to include other versions of ene eg, , assemblies, but overriding the default assemb| bindi : ., sted before deployment. ly binding can be risky and must be rigorously, , ingle unit Consisting of the runtime and, , te:, , BENEFITS OF .NET ASSEMBLIES, , , , 57, + Enable developers to specify versi, ersion rules betw: i, component! cen different software, , + Provide the infrastructure to enforce versioning rules., , + Provide the infrastructure to allow multiple versions of a component to be run, simultaneously (called side-by-side execution)., , + ASP.Net assemblies has a lot of good advantages when compare to conventional, DLLs that the developers use to develop earlier. In the case of DLLs if a DLL, has to be shared with some other application, it has to be registered in that, particular machine, But, In the case of Asp.net assemblies there is no such type, , of registration required,, , If one needs to share a particular assembly with any other applications., one can, do so by placing the assembly in the Global Assembly Cache (GAC). But before, doing it one needs to give a strong name to that assembly.Strong name is similar, to GUID(It is supposed to be unique in space and time) in CoM,, components.Strong Name is only needed when we need to deploy assembly in, Global Assembly Cache (GAC),Strong Names helps GAC to differentiate between, two versions. Strong names use public key cryptography (PKC) to ensure that, no one can spoof it. PKC use public key and private key concept., , i sing ASP.Net assemblies is the ability to read the contents, . thet has a manifest that has details about the assembly, , itself., , , , classes like ‘Assembly which can be used, , , , * The System.Reflection, to get the details o!, assembly dynamici, , Scanned with CamScanner
Page 5 :
a, , snmable Web pases that Serve as the, ce presents information 10 the user,, , nn logic using server-side code, wy a, ple language, including HTML, Xu, , , , ereate progral, One can use Web Forms PAB S foe Web Forms Pal, , ication. A, for the Web application: die, ee anaes era, , y HTTP-capal, Forms page output may cont almost » ah, WML, and ECMAScript (aScript, JavaSer, , , , , , Web Forms pages are. . in which code that FUNs On the seryg,, , ‘ nology t, - pada the browser of client device,, S, device, A Web Forms page automaticaly, HITML for features such as styles, layouy, ‘an your Web Forms pages to tun on g, plorer 5 and take advantage of, , + Based on Micro:, dynamically generate, , , , Compatible with any browser or mobil, , an, renders the correct browser-complian, and so on. Alternatively, you can Cf, specific browser such as Microsoft Internet Ex, the features of @ rich browser client., , + Compatible with any language supported, including Microsoft Visual Basic, Micro:, NET., , ‘+ Built on the Microsoft .NET F, , framework, including a manage, , by the NET common language runtime,, soft Visual C#, and Microsoft JScript, , ramework. This provides all the benefits of the, , /4 environment, type safety, and inheritance:, , + Supported in Visual Studio with powerful rapid application development (RAD), tools for designing and programming your forms,, , + Extensible using controls that provide RAD capability for Web development,, allowing creating rich user interfaces quickly., , , , + Flexible because one can add user-created and third party controls to them., , 5.8.1 Components of Web Forms, , In Web Forms pages, the user interface programming is divided into two distinct pieces:, the visual component andthe logic. The visual element is referred to as the Web Poms, page. The page consists of a file containing static HTML, or ASP.NET server controls, of, , , , ‘both simultaneously. |, , ‘The Web Forms page works as a container for the static text and controls the disp!, , pate Visual Studio Web Forms Designer plus ASP.NET server controls, one can, , The logic for e, , oe ee wed ie Page consists of code that is created to interact with, , eee separ il rom the user interface file, a an",, , Jogic written in the code-behind file can be written in, , , , sPX.Vb" or ".aspx.cs" extensi¢, Visual Basic or Visual C#., , , , , , , wee” . See eens, 82 web Forms File Structure |, MyWedFoem sic ., , orm aspx ———-L-_£88° Me WenForm, eyo Welcome), ge oD a My Woe Form, pestwors: Fa me, cao, | ion} =, ps), , ‘ath Files together make up MyWebForm, , , , Fig. 5.3, , The code-behind class files for all Web Forms pages in a proj i, , project dynamic-link library (dl) file. The ys cts cid ad, bifferently. The first time a user browses tothe. aspx page, ASP.NET automatically generates, a NET class file that represents the page, and compiles itto second il file. The generated, class for the .aspx page inherits from the code-behind class that was compiled into the, project .dll file, When a user requests the Web page URL, the il files run on the server and, for the page., , , , 5.9.1 Creating Buttons, , The Button control can be used to create a button, this control is as follows: (t's based on the WebControl clas, which in turn is based on the, , ina Web page. The class hierarchy of, , Control class), Object, Control, WebControl, Button, Web server button controls p, default, they're made into, looks like in HTML as:, <input type="submit", style="height:24px;widt, absolute; TOP: 75px" >, , , , , server when they'e clicked. s0 by, , , , , , , , Scanned with CamScanner