简体   繁体   English

从Visual Studio 2005升级到Visual Studio 2008

[英]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. 我已经将c#中的一个项目从Visual Studio 2005升级到Visual Studio 2008并生成了DLL。但是升级Visual Studio之后的DLL大小为6kb,升级前为16kb。 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?? 我还有一个问题,黑白文件夹和obj文件夹有什么区别?? which gives the correct dll in vs 2008 这在vs 2008中给出了正确的dll

File size: 文件大小:

By default, the .NET 3.5 compiler uses a file alignment of 512 bytes, where earlier versions use a larger size (4096). 默认情况下,.NET 3.5编译器使用512字节的文件对齐方式,而较早的版本使用更大的大小(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)) . MSDN(/ filealign(C#编译器选项)) This link includes instructions for how to set the property within Visual Studio. 此链接包含有关如何在Visual Studio中设置属性的说明。

Each section will be aligned on a boundary that is a multiple of the /filealign value. 每个部分将在/ filealign值的倍数的边界上对齐。 There is no fixed default. 没有固定的默认值。 If /filealign is not specified, the common language runtime picks a default at compile time. 如果未指定/ filealign ,则公共语言运行时将在编译时选择默认值。

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: bin和obj文件夹:

The bin folder is the output folder, and the obj directory is the intermediate output folder. bin文件夹是输出文件夹,而obj目录是中间输出文件夹。 Your built executables will be placed in the bin directory (of course all of this is customizable, but this is the default). 生成的可执行文件将放置在bin目录中(当然所有这些都是可定制的,但这是默认设置)。

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. 即使在使用Visual Studio 2008时(如Visual Studio 2005那样)以.NET 2.0为目标,您仍在使用Visual Studio 2008附带的新编译器。由于编译器不同,文件大小也会有所不同。

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. 作为其中一些差异的示例,Visual Studio 2008附带的msbuild版本现在提供了/ m选项,该选项使编译器可以使用多个CPU内核来优化其构建时间。

As Daniel Rose answered, the newer compiler will offer more optimizations. 正如Daniel Rose回答的那样,较新的编译器将提供更多优化。 You can still use a tool like Reflector to verify that the IL is the same between DLLs. 您仍然可以使用Reflector之类的工具来验证DLL之间的IL是否相同。

VS 2005 uses .NET 2.0, while VS 2008 allows you to use .NET 3.5. VS 2005使用.NET 2.0,而VS 2008允许您使用.NET 3.5。 Perhaps Microsoft optimized code generation? 也许微软优化了代码生成?

EDIT: As for bin & obj: 编辑:至于bin和obj:

All the intermediate files during compilation are placed in the intermediate directory (normally obj\\ConfigurationName). 编译期间,所有中间文件都放置在中间目录(通常为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. 在C#中,这可能是清单,缓存,资源,生成的文件,...在C / C ++中,它还包括每个编译文件的.obj文件。

The actual output (the DLL/EXE and PDB) are then copied to the output directory (normally bin\\ConfigurationName). 然后将实际输出(DLL / EXE和PDB)复制到输出目录(通常为bin \\ ConfigurationName)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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