+ All Categories
Home > Documents > Assemblies

Assemblies

Date post: 03-Nov-2015
Category:
Upload: shivuhc
View: 215 times
Download: 0 times
Share this document with a friend
Description:
C
9
ASSEMBLIES
Transcript
  • ASSEMBLIES

  • ASSEMBLYAssemblyManifestModuleMetadataILMethodsPropertiesFieldsMethodsPropertiesFields

  • Assemblies and the Global Assembly Cache An assembly is a fundamental building block of any .NET Framework application. For example, when you build a simple C# application, Visual Studio creates an assembly in the form of a single portable executable (PE) file, specifically an EXE or DLL.

    Assemblies contain metadata that describe their own internal version number and details of all the data and object types they contain.

    Assemblies are only loaded as they are required. If they are not used, they are not loaded. This means that assemblies can be an efficient way to manage resources in larger projects.

    Assemblies can contain one or more modules. For example, larger projects may be planned in such a way that several individual developers work on separate modules, all coming together to create a single assembly.

  • Assemblies Overview

    Assemblies have the following properties:Assemblies are implemented as .exe or .dll files.

    You can share an assembly between applications by placing it in the Global Assembly Cache.

    Assemblies must be strong-named before they can be placed in the Global Assembly Cache.

    Assemblies are only loaded into memory if they are required.

    You can programmatically obtain information about an assembly using reflection.

    If you want to load an assembly only to inspect it, use a method such as ReflectionOnlyLoadFrom.

    You can use two versions of the same assembly in a single application.

  • Features of Assembly The assembly contains MSIL code (from the compilation of your code), resources, and the metadata (which is data that describes the assembly). The metadata defines the following, among other things : Type information for the methods and public members in the assembly

    The name of the assembly

    Version information

    Strong-name information

    Culture that defines the clients language and cultural preferences

    A list of the files in the assembly

    A list of referenced assemblies

  • TYPES OF ASSEMBLIESThe Types of assemblies are as follows:Single fileMulti filePrivateSharedsatellite

  • Friend Assemblies An internal type or internal member in an assembly can be accessed from another assembly.// cs_friend_assemblies.cs // compile with: /target:library using System.Runtime.CompilerServices; using System; [assembly:InternalsVisibleTo("cs_friend_assemblies_2")] // internal by default class Class1 {public void Test() { Console.WriteLine("Class1.Test"); } } // public type with internal member public class Class2 { internal void Test() { Console.WriteLine("Class2.Test"); } }

  • // cs_friend_assemblies_2.cs //compilewith:/reference:cs_friend_assemblies.dll/out:cs_friend_assemblies_2.exe public class M { static void Main() { // access an internal type Class1 a = new Class1(); a.Test(); Class2 b = new Class2(); // access an internal member of a public type b.Test(); } }


Recommended