Click here to Skip to main content
13,801,691 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11.5K views
13 bookmarked
Posted 11 Jun 2018
Licenced CPOL

C# bin vs obj Folder

, 11 Jun 2018
Rate this:
Please Sign up or sign in to vote.
bin vs obj folder in C#

When you compile C# programs, you would see 2 folders “bin” and “obj”. In this article, we will try to understand the difference and importance of these folders.

Both these folders have compiled IL code, but the question is why not just one folder and why two folders?

We have two folders because the compilation process goes through two steps, compiling and linking. See the below diagram.

  • In compiling phase, every code file is compiled into individual compiled units. So if you have two code files, two independent compiled codes will be generated.
  • In linking phase, all these compiled code files are linked and compiled into a single unit assembly which can be a DLL or EXE.

If you compare both the folders (see the below image), you will find more files in “obj” folder as compared to “bin” folder. We have more files in “obj” folder because it creates separate compiled code files for each source code file.

So the next question which comes to our mind is why do we need compiling in two phases, why not just do it in one go. By doing the two phase compiling, we achieve incremental or conditional compiling.

When we work with big projects, we will have a lot of code files and we would like to only compile those code files which have changed. In the “obj” folder we have entry of each code file compilation. So we can know from the same which files exactly have changed, thus making compiling fast.

In summary, in “obj” folder, we have compiled files for each source code file and in “bin” folder, we have a single unit which links all individually compiled code files.

Below is a 10 minute YouTube video which demonstrates how both these folders look like and how incremental compilation happens.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Comments and Discussions

 
Generaldoes Visual Studio use NMAKE utility to implement this? Pin
Southmountain16-Jun-18 10:24
memberSouthmountain16-Jun-18 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.181215.1 | Last Updated 11 Jun 2018
Article Copyright 2018 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid