Information Tech Box (ASP.Net Querys)

difference between dll and exe files
===========================

.exe is an executable program while .dll is dynamic link library. 

Both are assemblies. So whatever the difference lies between program and library, same is between .exe and .dll like:

1. .dll can be shared with many .exe files. Basically it's an external code repository for .exe programs. Since usually several different programs reuse the same DLL instead of having that code in their own file, this dramatically reduces required storage space.

2. Both files are PE (Portable Executable) files. Both contain the exact same layout. A DLL is a library and therefore cannot be executed. If you try to run it you'll get an error about a missing entry point (main function).  An EXE is a program that can be executed. It has an entry point.  A flag inside the PE header indicates which file type it is (irrelevant of file extension). The PE header has a field where the entry point for the program resides. In DLLs it isn't used (or at least not as an entry point). So, .exe files are used for launching an application (it contains a startup function), whereas DLLs are loaded into an application (i.e. they can't run by themselves).

3. Only one .exe file exists per application but there can be many dlls in applications.

So, in summary, EXEs are executable programs while DLLs are libraries loaded into a process and contain some sort of useful functionality like security, database access or something.



=============================
==========================================

.NET assemblies correspond to .class files that contain byte code.
.NET assemblies are the files that result from compiling a .NET program so a .exe file or a .dll file are both called assemblies.


A .NET assembly not only does it contain MSIL (which is now called Common Intermediate Language CIL) but it also contain resources and meta data. Finally, you can use the ildasm.exe tool to get the disassemble an assembly into intermediate language. It comes with your Visual Studio installation.

You can use ildasm.exe to extract the IL from the assembly compiled by csc.exe.


C# Delegates:

 

A Simple Example of Delegates

 
 
using System;
public class Test
 {
  public delegate int CalculationHandler(int x, int y);
  static void Main(string[]  args)
   {
     Math math = new Math();
    //create a new instance of the delegate class

     CalculationHandler sumHandler = new CalculationHandler(math.Sum);
    //invoke the delegate
      int result = sumHandler(8,9);
     Console.WriteLine("Result is: " + result);
     }
   }

 public class Math
  {
    public int Sum(int x, int y)
     {
       return x + y;
     }
  }

 

 

1 comment:

रूस-यूक्रेन संकट लाइव: भारतीयों को 'उपलब्ध किसी भी साधन' के माध्यम से कीव को तत्काल छोड़ने के लिए कहा

  रूस यूक्रेन संकट लाइव: कीव में भारतीय दूतावास ने मंगलवार को जारी एक एडवाइजरी में भारतीयों को  'किसी भी उपलब्ध साधन' के माध्यम से क...