Sunday, 23 February 2014

Interview Questions On Assemblies In .NET

Interview Questions On Assemblies In .NET

Q: What is GAC (Global Assembly Cache)?
A: GAC is a central repository folder where you can store and share your DLL among different applications running in the same computer. So for example you have accounting and invoicing application running in the same computer and both these application need some common utility like the logging DLL then you need to register them in GAC and share with them this dll from one common location instead of referencing the logging dll from logging project bin directory.

Q: If we have different versions of DLL in GAC how can the application identify them?
A: This is done by using binding redirect and specifying older version and new version value. So which ever version you put in the new version will be used by the application. 
  

Saturday, 22 February 2014

Assemblies in .NET

Assemblies in .NET

Introduction:

  1. In the Microsoft .NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security. There are two types: process assemblies (EXE) and library assemblies (DLL). A process assembly represents a process which will use classes defined in library assemblies. .NET assemblies contain code in CIL, which is usually generated from a CIL language, and then compiled into machine language at run time by the CLR just-in-time compiler.
  2. An assembly can consist of one or more files. Code files are called modules. An assembly can contain more than one code module and since it is possible to use different languages to create code modules it is technically possible to use several different languages to create an assembly. Visual Studio however does not support using different languages in one assembly.
  3. When you compile an application, the MSIL code created is stored in an assembly . Assemblies include both executable application files that you can run directly from Windows without the need for any other programs (these have a .exe file extension), and libraries (which have a .dll extension) for use by other applications. Assemblies can be Process Assemblies i.e exe files or Library Assemblies i.e dll files. Process assemblies are the processes which use library assemblies in their execution.
  4. Even though assembly  word can be used for EXE's as well but it mainly refers to Dll's. Assemblies are also called Portable Executable s (PE) as they can be easily carried and executed on any other system having CLR installed.