C# – Why the .NET framework takes so long to install? Why is it complex to make it portable

asp.net-4.0cinstallationnet

I am asking this question primarly to learn. Let's say I want to send a very small console application (50 lines of code Also I am using the System.Text.RegularExpresion namespace.) to a friend writen on c# on .net framework 4.0 . I will like to make the application portable therefore I just send him the output of the bin directory.

Why does he has to install the .net framework 4.0 client which it takes quite a while. Also it will be nice to include only the dll libraries that I plan on using in this case system.dll (that library contains system.text.regularexpressions namespace).

In other words why is it that I cannot include system.dll in my console application in order to make it portable and for it to work on a computer that does not have the .net framework installed.

Why is the installation of .net framework 4.0 so complex? What would happen if windows where to place all .net libraries on C:\Program Files\.net framework 4.0\ and then on the installation write a key to the registry of the path where that framework was installed so that programs are able to find the nessesary dlls.

Why are installations so complex on general?

I tried to decomplile system.dll with reflector then include that on my project and that did not worked

Edit

I guess my question should have been why .net framework 4.0 takes so long to instal? Why is it not posible to run the .net framework 4.0 if windows where to place the necessary dlls on program files and then write to the registry the path where those dlls are located. That process would have been much faster. Why not do it that way?


So in conclusion

Thanks for the help I understand now how important is the CLR. I guess the only part that I am missing to understand is why installations take so long. I understand that there are thousands of dlls. Unziping those dlls to program files and writing 10000 keys on the registry should be much more quicker.

Best Answer

Your question seems to boil down to "Why do I need to install the entire .NET Framework, instead of including just the required DLL's?"

The answer is that .NET Framework consists of more than just DLL's. The other major component of the framework is the CLR, which is in charge of executing and managing .NET code. The .NET Framework consists of many other smaller things (such as compilers) which are not necessary to run code, but nevertheless included with the framework.

The CLR is more important to .NET than the DLL's themselves. It is analogous to the CPU on a computer. Without it, nothing can be done, and the executable programs you have are just garbage data. The CLR takes care of JIT compiling your code to a native executable, memory management, etc. It is very similar in concept to the JVM for Java applications.

Even the DLL's are more complex than it would seem. Although you could in theory (disregarding the CLR for a minute) deploy just the dependency DLL's with your application, remember that all those DLL's (with the exception of mscorlib) have dependencies on more DLL's, and so on, including a vast number of dependencies for a simple application.