Frequently Asked Interview Questions

Dotnet Framework Interview Questions


Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.
Assemblies are a fundamental part of programming with the .NET Framework. An assembly performs the following functions:
  • It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note that each assembly can have only one entry point
  • It forms a security boundary. An assembly is the unit at which permissions are requested and granted.
  • It forms a type boundary. Every type's identity includes the name of the assembly in which it resides. A type called TypeX loaded in the scope of one assembly is not the same as a type called TypeX loaded in the scope of another assembly.
  • It forms a reference scope boundary. The assembly's manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends.
  • It forms a version boundary. The assembly is the smallest versionable unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. The assembly's manifest describes the version dependencies you specify for any dependent assemblies.
  • It forms a deployment unit. When an application starts, only the assemblies that the application initially calls must be present. Other assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This allows applications to be kept simple and thin when first downloaded.
  • Multiple versions can be deployed side by side in different folders. Thesedifferent versions can execute at the same time without interfering with eachother.

  • Assemblies can be static or dynamic: Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in PE files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.There are several ways to create assemblies. You can use development tools, such as Visual Studio .NET, that you have used in the past to create .dll or .exe files. You can use tools provided in the .NET Framework SDK to create assemblies with modules created in other development environments. You can also use common language runtime APIs, such as Reflection.Emit, to create dynamic assemblies.

    In general, a static assembly can consist of four elements:
  • The assembly manifest, which contains assembly metadata.
  • Type metadata.
  • Microsoft intermediate language (MSIL) code that implements the types.
  • A set of resources.

  • Assembly Manifestdescribes the assembly with all the information that is needed to reference it and lists all its dependencies. The parts of the assembly manifest are as follows:
    Identity - (name, version,culture, and public key)
    A list of files -Files belongs to this assembly. A single assembly must have at least one file but may contain a number of files.
    A list of referenced assemblies -All assemblies used from the assembly are documented inside the manifest. This reference information inludes version number and public key, which is used to uniquely identify assemblies.
    A set permission requests -These are the permissions needed to run this assembly.
    Exported types -These are included if they are defined within a module and the module is referenced from the assembly. otherwise, they are not part of the manifest. A module is a unit of reuse. The type description is stored as metadata inside the assembly.

    assembly manifest - An integral part of every assembly that renders the assembly self-describing. The assembly manifest contains the assembly's metadata. 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 self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.
    metadata - Information that describes every element managed by the common language runtime: an assembly, loadable file, type, method, and so on. This can include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime.

    Using Reflection.

    Version information is stored in assembly in manifest.

    Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie inthere individual folders.

    NameSpace Logically group types.
    Ex: System.Web.UI logically groupsour UI related features.

  • Assembly is physical grouping of logical units. Namespace logically groupsclasses.
  • Namespace can span multiple assembly.

  • There are two ways to install .NET assembly in GAC:-
  • Using Microsoft Installer Package.You can get download of installer fromhttp://www.microsoft.com.
  • Using Gacutil. Goto “Visual Studio Command Prompt” and type “gacutil –i(assembly_name)”.Where (assembly_name) is the DLL name of the project.

  • During development process you will need strong name keys to be exposed to developer whichwill is not a good practice from security aspect point of view.In such situations you can assign thekey later on and during development you an use delay signing

    Following is process to delay sign a assembly:
  • First obtain your string name keys using SN.EXE.
  • Annotate the source code for the assembly with two custom attributes fromSystem.Reflection: AssemblyKeyFileAttribute, which passes the name of the filecontaining the public key as a parameter to its constructor. AssemblyDelaySignAttribute,which indicates that delay signing is being used by passing true as a parameter to itsconstructor

  • For Example:
    [assembly:AssemblyKeyFileAttribute("myKey.snk")]
    [assembly:AssemblyDelaySignAttribute(true)]

    The compiler inserts the public key into the assembly manifest and reserves space in the PE file forthe full strong name signature. The real public key must be stored while the assembly is built sothat other assemblies that reference this assembly can obtain the key to store in their own assemblyreference.
  • Because the assembly does not have a valid strong name signature, the verification ofthat signature must be turned off. You can do this by using the –Vr option with theStrong Name tool.The following example turns off verification for an assembly calledmyAssembly.dll.


  • Sn –Vr myAssembly.dll

    Just before shipping, you submit the assembly to your organization's signing authorityfor the actual strong name signing using the –R option with the Strong Name tool.Thefollowing example signs an assembly called myAssembly.dll with a strong name usingthe sgKey.snk key pair

    Sn -R myAssembly.dll sgKey.snk

    Garbage collection is a CLR feature which automatically manages memory.CLR automatically releases objects when they are no longerreferenced and in use.CLR runs on non-deterministic to see the unused objects and cleans them.One side effect of this non-deterministic feature is that we cannot assume an object is destroyedwhen it goes out of the scope of a function. Therefore, we should not put code into a classdestructor to release resources.

    System.GC.Collect() forces garbage collector to run.This is not recommended but can be used ifsituations arises.

    All .NET assemblies have metadata information stored about the types defined in modules.Thismetadata information can be accessed by mechanism called as “Reflection”.System.Reflection canbe used to browse through the metadata information.

    Using reflection you can also dynamically invoke methods using System.Type.
    JIT compiler is a part of the runtime execution environment.
    In Microsoft .NET there are three types of JIT compilers:

  • Pre-JIT. Pre-JIT compiles complete source code into native code in a single compilationcycle. This is done at the time of deployment of the application.


  • Econo-JIT. Econo-JIT compiles only those methods that are called at runtime.However, these compiled methods are removed when they are not required.


  • Normal-JIT. Normal-JIT compiles only those methods that are called at runtime.These methods are compiled the first time they are called, and then they are stored incache. When the same methods are called again, the compiled code from cache isused for execution.

  • Most Visited Pages

    Home | Site Index | Contact Us