views:

142

answers:

3

I have upgraded one of my projects in c# from visual studio 2005 to visual studio 2008 and and generated DLL .But the size of DLL after upgadring visual studio is 6kb which was 16 kb before upgrade. Why the size has reduced?? Will this give any issue??

I have one more question what is the difference b/w bin and obj folders?? which gives the correct dll in vs 2008

A: 

VS 2005 uses .NET 2.0, while VS 2008 allows you to use .NET 3.5. Perhaps Microsoft optimized code generation?

EDIT: As for bin & obj:

All the intermediate files during compilation are placed in the intermediate directory (normally obj\ConfigurationName). In C# this may be manifests, caches, resources, generated files, ... In C/C++ that also includes a .obj file for each compiled file.

The actual output (the DLL/EXE and PDB) are then copied to the output directory (normally bin\ConfigurationName).

Daniel Rose
-1: Doesn't answer any of the OP's questions.
280Z28
+1  A: 

Even if you target .NET 2.0 while using Visual Studio 2008 (as Visual Studio 2005 did), you're still using the new compiler that ships with Visual Studio 2008. The file sizes will be different because of the different compiler.

As an example of some of the differences, the version of msbuild that ships with Visual Studio 2008 now offers the /m option, which lets the compiler optimize its build time using multiple CPU cores.

As Daniel Rose answered, the newer compiler will offer more optimizations. You can still use a tool like Reflector to verify that the IL is the same between DLLs.

David Mohundro
Technically this is correct, but it varies from trivial (he already knows the different compiler produces a different size) to irrelevant to the question (/m).
280Z28
+2  A: 

File size:

By default, the .NET 3.5 compiler uses a file alignment of 512 bytes, where earlier versions use a larger size (4096). Aside from the possibility of using different preprocessor directives over large sections of the code, this is the most likely explanation. The tighter alignment produces smaller binaries and will not cause any problems.

Edit: As requested, more information about this option. From MSDN (/filealign (C# Compiler Options)). This link includes instructions for how to set the property within Visual Studio.

Each section will be aligned on a boundary that is a multiple of the /filealign value. There is no fixed default. If /filealign is not specified, the common language runtime picks a default at compile time.

By specifying the section size, you affect the size of the output file. Modifying section size may be useful for programs that will run on smaller devices.

bin and obj folders:

The bin folder is the output folder, and the obj directory is the intermediate output folder. Your built executables will be placed in the bin directory (of course all of this is customizable, but this is the default).

280Z28
thanks for your reply , but iam not clear with your answer can you ellaborate it or provide a best link for me to understand
I have one more question what is the difference b/w bin and obj folders?? which gives the correct dll in vs 2008
@jbp117: The bin folder is the output folder, and the obj directory is the intermediate output folder. Your built executables will be placed in the bin directory (of course all of this is customizable, but this is the default).
280Z28
Target framework of vs 2008 is .net 2.0... ,the default file alignment is 4096bytes for vs 2005 but it is 512 bytes for vs 2008.This is the reason, what your are saying am I right ?
Yes, that is the reason your file is smaller.
280Z28