C# beginners :- Assembly , EXE and DLL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we will try to understand what exactly is termed as assembly a exe and a dll now if we go to Microsoft comm and if you try to read the definition of assembly it says that it is a fundamental unit of deployment now English is my second language I know if you are a person who is from us or from UK or from an english-speaking country you can understand this but believe me when I first read this it was very difficult for me to understand what exactly it means right so let me put in simple word but assembly is nothing but it is a pre compiled chunk of dotnet code it is a pre compiled chunk of dotnet code which can be run by the CLR so in other words for example now you can see over here that I have a very simple project you know called as my console right and if you see this my console if I go to the folder of my console I see lot of things you know I see the source code program dot CS I see the config file I see assembly info dot CS and lot of things but when I go and hit this build button when I say build over here right what it does is it actually goes and puts this whole thing into a single exe a single unit so you can see this my console over here is a single unit now what I can do is I can go and copy this and I can run this program anywhere so basically I can go and just put this in my user like this I can paste it and I can just run this so you can see now I know that there is nothing happening in the application but the point is that this is a single unit of deployment I can copy this without copying the other files and put it on my production environment so assembly is nothing but it is a single unit of deployment or if you put in simple words it is a the chunk of coal it is a precompiled chunk of code which can be executed by the CLR now assemblies can be of various types for example we just saw assembly which is a exe executable and the other kind of assemblies you know what we can have is a dll for example if I go and I add a project of our type class library it becomes a dll for example you can see that I will just add a class library over here I will turn this as as my tll so now in this project in this solution I have two assemblies one is a type of exe so this my console is a type of exe and this is a type of tll so if I build this project very quickly if I rebuild this and if I go to my project over here you can see now in this my console in this this in this my console I have this assembly my console exe and in the my DLL AHA I have my dll DLL so this is the dll DLL stands for dynamic link library and exe is nothing but the executable so now the next question which comes is that so what is the difference between a DLL and a Exe a Exe actually runs in his own address space in his own memory space for example if I go and write here console dot a right line right let us say hello right also let me just say console not read so that we can wait so if I now build us okay and if I go to my project over here and if I see this my console if I go to the bin directory and if I click on my console now this program out here this exe out here is running in his own address space if I again click you can see now I have to exe s this exe is running in his own memory address and this exe is running in his own memory address right so both of them are having separate memory addresses but if you see a DLL right so if you see this DLL out here which I have this my tll this my DLL cannot invoke by himself he needs a host er he needs a consumer who will invoke it so a DLL will actually run inside some other memory space so there will be a console application must be and that console application will consume this DLL and he will run in the address space of that exe so for example if I want to use this DLL so I will add a reference so let me add a reference out here right and what I will do is inside this DLL I will just say hello in case you are new to these keywords like namespace and class what I would suggest is please go and watch the object-oriented programming videos you know what we have on corresponding video calm so I will not explain them now at this moment our concentration is to understand assembly exe and DLL right so let us say I have a simple method out here and over here I will just say return this is from DLL right so now I am going to go and run this DLL inside this my console so this this thing out here cannot run by itself the DLL cannot run in his own address space it will actually run inside some hoster so over here I will now go and add a reference of this my DLL it is already done so now I can go here and say ok I want to use the DLL right and in his address space that means in the exas address space now we will go and create the object of class one right and we say console dot write line obj dot method right so if you now see in this case when I run this exe this DLL will be running in the address space of that exe you can see now this that the DLL you know what we have is now hosted inside the address space of the exe so exe actually runs in his own address space but a DLL runs in has does not have his own address space and it needs a host ER or a consumer to invoke him so why do we have these concepts separately I am going to say like why do we have a exe which can run in his own address space and then why we have a DLL a dynamic link library which actually runs inside the address space of some other hoster the whole point of of a DLL or or of a library I will say rather is nothing but you know for reusability for example now think about it ah you know this my DLL you know if I want to go and reuse it in to some other project it is very easy right I can just add a reference and then invoke it so basically whatever code you want to reuse what people do is you know they go and put into a DLL and then they consume into exe s ok so the whole point of DLL is of reusability so you create the DLL once and then you can host it inside a console application you can host it inside a Windows application you can host it in tight inside asp.net application so all the other applications out there you know are you know they can run by themselves you know but a DLL you know will will run inside address space of whose hostess so the whole point of DLL is reusability and the whole point of Exe is is to just run in its own address space and start executing the code so I hope that you enjoyed this session in this session we were trying to understand what exactly is assembly what is the exe and what is a DLL thank you so much
Info
Channel: .NET Interview Preparation videos
Views: 183,672
Rating: undefined out of 5
Keywords: C# for beginners, C# training, learn C#, .NET for freshers, C# freshers tutorial, dotnet assembly, Assembly architecture, EXE assembly, DLL assembly, assembly in dot net, c# programming, c# tutorial, exe and dll, dynamic link library, executable file, exe and dll c#, what is dll, what is exe, learn .net assembly, assembly .net, c# tutorial for beginners, programming freshers, assembly vs dll, exe vs assembly
Id: lx2tSY4joDg
Channel Id: undefined
Length: 9min 53sec (593 seconds)
Published: Tue Aug 23 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.