Saturday, 5 September 2015

Page Directives in ASP.NET

Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:
  1. @ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.
  2. @ Register - Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.
  3. @ Assembly - Links an assembly to the current page or user control declaratively. 
  4. @ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).
  5. @ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively. 
  6. @ Import - Imports a namespace into a page or user control explicitly.
  7. @ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.
  8. @ MasterType - Defines the class or virtual path used to type the Master property of a page.
  9. @ OutputCache - Controls the output caching policies of a page or user control declaratively.
  10. @ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.
  11. @ Reference - Links a page, user control, or COM control to the current page or user control declaratively.

Page Life Cycle in ASP.NET

  • Page_PreInit
  • Page_Init
  • Page_InitComplete
  • Page_PreLoad
  • Page_Load
  • Page_LoadComplete
  • Page_PreRender
  • Render


Generalization & Specialization in OOPS

Generalization:
The concept of generalization in OOP means that an object encapsulates common state and behavior for a category of objects.

Example: The geometric shape is an object and most geometric shapes have area, perimeter, and color.

Specialization:
The concept of specialization in OOP means that an object can inherit the common state and behavior of a generic object. However, each object needs to define its own special and particular state and behavior.

Example: Each geometric shape has its own color and particular formulas to calculate its area and perimeter.

Various .Net Tools

What is Ilasm.exe used for?
Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected.

What is Ildasm.exe used for?
Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.

What is the ResGen.exe tool used for?
ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies.

Strong Name Tool (Sn.exe) used for?
Sn.exe is a tool that is used to generate strong name. eg: sn -k mykey.snk

What is the caspol.exe tool used for?
The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.


Some more tool will be added shortly ! Please wait.... 

A short description about .Net Assembly

What is an assembly?
An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework.
An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality.

What are the contents of assembly?
A static assembly can consist of four elements:
1. Assembly manifest - An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
2. Type metadata - Binary information that describes a program.
3. Microsoft intermediate language (MSIL) code.
4. A set of resources.

What are the different types of assembly?
1. Private assembly: A private assembly is installed in the installation directory of an application and is accessible to that application only.
2. Shared assembly: Shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.
3. Satellite assembly: Satellite assemblies are often used to deploy language-specific resources for an application.

What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.

What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly.
The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.

What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Steps
Create a strong name using sn.exe tool eg: sn -k mykey.snk
In AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
recompile project, and then install it to GAC in two ways :
Drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)
gacutil -i abc.dll