none
What is the difference between .dll and .exe ? RRS feed

  • Question

  • Hi
     
    Could any body tell  please tell me the difference between .dll file and .exe file ?

    Thanks,
    Tuesday, June 12, 2007 12:45 PM

Answers

  • Well the most obvious difference is that EXE files are used for launching an application (it contains a startup function etc), whereas DLLs are loaded into an application (ie they can't run by themselves).

     

    Tuesday, June 12, 2007 12:52 PM

All replies

  • Well the most obvious difference is that EXE files are used for launching an application (it contains a startup function etc), whereas DLLs are loaded into an application (ie they can't run by themselves).

     

    Tuesday, June 12, 2007 12:52 PM
  • Two things: the extension and the header flag stored in the file.

     

    Both files are PE files.  Both contain the exact same layout.  A DLL is a library and therefore can not be executed.  If you try to run it you'll get an error about a missing entry point.  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). 

     

    One minor difference is that in most cases DLLs have an export section where symbols are exported.  EXEs should never have an export section since they aren't libraries but nothing prevents that from happening.  The Win32 loader doesn't care either way. 

     

    Other than that they are identical.  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.

     

    Michael Taylor - 6/12/07

    http://p3net.mvps.org

    • Proposed as answer by avidadi2002 Monday, January 18, 2010 12:00 PM
    Tuesday, June 12, 2007 12:53 PM
    Moderator
  •  

    DLL - Dynamic Link Library

                  

    An ActiveX Dll runs is an in process server running in the same memory space as the client process.

     

    EXE – Executable File

     

    An ActiveX Exe is an out of process server which runs in its own separate memory space.

    Advantages of ActiveX Dll
    -------------------------
    1) An in-process component shares its client’s address space, so property and method calls don’t have to be marshaled. This results in much faster performance.

    Disadvantages of ActiveX Dll
    ----------------------------
    1) If an unhandled error occurs it will cause the client process to stop operating.

    Advantages of ActiveX Exe
    -------------------------
    1) The component can run as a standalone desktop application, like Microsoft Excel or Microsoft Word, in addition to providing objects.
    2) The component can process requests on an independent thread of execution, notifying the client of task completion using events or asynchronous call-backs. This frees the client to respond to the user.
    3)If an error occurs the client processes can continue to operate.

    Disadvantages of ActiveX Exe
    ----------------------------
    1) Generally slower than an ActiveX dll alternative
    Monday, May 26, 2008 3:50 PM
  • The DLL is an inprocess component but exe is outprocess component. When system launches an exe, a new process is created , for DLL a new process is not created.

    DLL is a WIN 32 LIBRARY file, whereas the exe is a WIN32 executable file.

    DLL can be reused and versioned. DLL reduces storage space as different programs/files can use the same dll.

    DLL does not have a main function. DLL binding occurs at runtime. That is why its called "Dynamic Link" library.

    EXE has a single main entry point.

    Pls see Jeffrey Richter's "Programming with .NET Framework"  for more details.

     

     

     

    Wednesday, March 31, 2010 5:37 AM
  • the main difference between .dll and .exe is that .dll has no main function and .exe has main function that is the reason .dll is not open directly and .exe opens directly

    Monday, March 21, 2011 5:02 AM
  • Main difference between .dll and .exe.

    .dll                                                   .exe

    It is not open directly (Means execute)          It is open directly (Means execute)

     

     

    Thanks

    Alok Kumar Sharma

     

     

     

     


    Alok Kumar Sharma

    Saturday, June 11, 2011 5:06 AM
  • Both .dll and .exe are binary files

     

    DLL: Dynamic Link Library, its a library of functions. DLL files do not have an entry point-start up function(main function from where program execution starts).  It is loaded dynamically with in a process execution hence it is a in process component. DLLs are faster in performance  as compared to EXEs.  If exceptions are not handeled with in functions of DLL then it will cause process to terminate.

     

    EXE: Executable files, it is also a library of functions but they do have an entry point from where the program execution starts. It is an out of process component. slower in performance as compared to DLLs.

     

    Sunday, July 17, 2011 1:20 PM
  • Can you elaborate your points with an example if possible ?

    Wednesday, September 4, 2013 8:25 AM
  • <copied>

    the main difference between .dll and .exe is that .dll has no main function and .exe has main function that is the reason .dll is not open directly and .exe opens directly

    <end>

    That's not quite true and a DLL can have a Main, like in the example code of the Server classlib project (a DLL).

    namespace WCFSimple.Server
    {
        public class Program
        {
            private static AutoResetEvent stopFlag = new AutoResetEvent(false);

            /// <summary>
            /// The main entry point for the application.
            /// </summary>
          
            public static void Main()
            {
                var svh = new ServiceHost(typeof(ServiceImplementation));

                //svh.AddServiceEndpoint(
                //     typeof(IService),
                //        new NetTcpBinding(),
                //     "net.tcp://localhost:8000");

                svh.AddServiceEndpoint(
                    typeof (IService),
                    new NetNamedPipeBinding(),
                    "net.pipe://localhost/Pipe");

                 svh.Open();

                 Console.WriteLine("SERVER - Running...");

                 stopFlag.WaitOne();

                 Console.WriteLine("SERVER - Shutting down...");

                 svh.Close();

                 Console.WriteLine("SERVER - Shut down!");

              }

              public static void Stop()
              {
                 stopFlag.Set();
              }
         }
    }

    The console program that starts the Server's Main.

    using System;
    using System.ServiceModel;

    namespace WCFSimpleConsole
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("WCF Simple Demo");

                // start server

                var thServer = new System.Threading.Thread(WCFSimple.Server.Program.Main) {IsBackground = true};

                thServer.Start();

                System.Threading.Thread.Sleep(1000);  // wait for server to

                // run client

                ChannelFactory<WCFSimple.Contract.IService> scf;

                //scf = new ChannelFactory<WCFSimple.Contract.IService>(
                //          new NetTcpBinding(),
                //            "net.tcp://localhost:8000");


                scf = new ChannelFactory<WCFSimple.Contract.IService>(
                         new NetNamedPipeBinding(),
                           "net.pipe://localhost/Pipe");

                WCFSimple.Contract.IService s;

                s = scf.CreateChannel();

                while (true)
                {
                    Console.Write("CLIENT - Name: ");

                    string name = Console.ReadLine();

                    if (name == "") break;

                    string response = s.Ping(name);

                    Console.WriteLine("CLIENT - Response from service: " + response);
                }

                (s as ICommunicationObject).Close();

                // shutdown server

                WCFSimple.Server.Program.Stop();

                thServer.Join();

            }
        }
    }

     

    Wednesday, September 4, 2013 10:20 PM
  • "Both .dll and .exe are binary files" I don't think so..

    As per my study both contain data in the form of IL/MSIL (because compilation done in two phases. In which the first is language compiler that convert source code into MSIL/IL code and stored it into in this assembly file) and at run time depending on target environment, JIT compiler can convert this data into native code i.e. in binary.

    If you think that I'm wrong then please post your answer.

    Thanks


    Wednesday, July 12, 2017 12:06 PM