简体   繁体   中英

upgrading from visual studio 2005 to visual studio 2008

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

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).

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM