In Microsoft Visual Studio 2005, when I go to create a minimal Windows based application, the resulting source code created is 77 lines of code and seven references, with a release compiled executable of 16k in size.
Doing the same thing in Visual Studio 2010 retains the same generated code size, and the release executable is 7k in size.
So I set about creating a minimal C# application in C#.
The following 27 lines of code which compiles to 4k in size, when manually doing the compile from the command line, is completely self contained and does not leave a container or vshost up after running, and does precisely the same thing as the others do visually.
Here’s the command line switches.
csc /noconfig /unsafe+ /nowarn:1701,1702 /platform:x86 /baseaddress:285212672 /define:DEBUG;TRACE /reference:C:\WINDOWS\assembly\GAC\Microsoft.DirectX.Direct3D\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.Direct3D.dll /reference:C:\WINDOWS\assembly\GAC\Microsoft.DirectX.Direct3DX\1.0.2911.0__31bf3856ad364e35\Microsoft.DirectX.Direct3DX.dll /reference:C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /debug+ /t:winexe /out:main.exe main.cs
Interestingly enough, Visual Studio 2010, when reduced to the absolute bare bones project and only this file. Results in a file size of 5k.
And Oh My God are the compilations so much faster.
There’s absolutely something to be said about the help Microsoft brings to coding when leveraging their tools.
But as I’ve been learning.
Question what you’re told is the only way to do things. You’ll learn a lot in the process and might find your own way somewhere in there.