Assemblies in asp
Upcoming SlideShare
Loading in...5
×
 

Assemblies in asp

on

  • 170 views

 

Statistics

Views

Total Views
170
Views on SlideShare
170
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Assemblies in asp Assemblies in asp Presentation Transcript

  •  An assembly is a fundamental unit of any .NET application. It contains the code that is executed by CLR (common language runtime).  An assembly contains name, version, types (classes and others) created in it and details about other assemblies it references.  An assembly may be either an executable file - .EXE or a dynamic link library - .DLL
  •  The following is the content of an assembly. Each assembly contains first three parts. Fourth part may not be present in all assemblies. It is used primarily for localization - using resources according to the country or region.  Assembly Metadata or Manifest  Type Metadata  MSIL Code  Resources
  •  This contains information about the assembly.assemblies in .NET are self-describing. They contain all the information that .NET needs to use them. Assembly metadata contains the following details of an assembly: Assembly name  Version number of the assembly, which has four numbers in the format major.minor.revison.build  Culture - language assembly supports  Strong name - required only for global assemblies  List of files in the assembly. An assembly can be made up of multiple files  Type reference information - informs which type is in which file of the assembly  Information about referenced assemblies - View slide
  •  This section of an assembly contains information about all classes, structure etc. created in the assembly. View slide
  •  MSIL code of the assembly is placed in third part of the assembly. This MSIL is converted to native code by CLR at runtime.
  •  This section contains messages and pictures used by assembly.
  •  Select File->New Project From Templates, select Class Library .  Enter name CounterLibrary.  A class library is created using a single class Class1 .Rename class to Counter and add the following code.  namespace CounterLibrary  {  public class Counter  {  protected int v = 0;
  •  public Counter(int v)  {  this.v = v;  }  public int Value  {  get  {  return v;  }  }
  •  Save project using File->Save All. When prompted to enter location for project, select the folder where you want to save your project  Build (not run) the project using Build->Build Solution
  •  Start Visual C# 2005 Express Edition  Create a new console application using File -> New Project From template select Console Application as type of project  Give name UseCounter for application. A new application is created with a single class with Main() method.  Go to Solution Explorer and select project Right click on it and select Add References from the context menu. From dialog box, select Browse tab and select c:csharpcounterlibrarybinreleasecounterlib rary.dll Solution explorer displays counterlibrary as one of the references under references node in solution explorer  Add the following code in Main() method of Program.cs
  •  static void Main(string[] args)  {  CountLibrary.Counter c = new CountLibrary.Counter(100);  c.Inc();  Console.WriteLine(c.Value);  Console.ReadLine();  }  Run and test the application.
  •  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 version, a 64 bit hash of a public key (called a ´token´) and the culture.
  •  Any assembly that is to be placed in GAC, must have a strong name. Strong name is a combination of public key and private key. The relationship between public and private keys are such, given one you cannot get the other, but any data that is encrypted with private key can be decrypted only with the corresponding public key. Take the following steps to invoke SN (Strong Name) tool to create strong name.  Go to command prompt using Microsoft .NET Framework SDK v2.0 -> SDK Command prompt  Go to c:csharpcounterlibrary folder and enter the following command.  sn -k srikanth.key The above command writes private and public key pair into srikanth.key file.