如何最小化ASP.NET C#项目DLL大小?

时间:2022-07-16 01:40:39

I´m working on a project, in Visual Studio 2008, which DLL currently surpasses 20 MB. Is there a way to profile that DLL, searching the main contributors to this size?

我正在使用Visual Studio 2008中的一个项目,该DLL目前超过20 MB。有没有办法分析该DLL,搜索这个大小的主要贡献者?

I suspect that breaking it in smaller projects inside the solution would help, but I'm looking for a faster solution (although not better, I'm afraid).

我怀疑在解决方案中的小项目中打破它会有所帮助,但我正在寻找更快的解决方案(虽然不是更好,我害怕)。

As a sidenote, we are getting 'unexpected error writing metadata' error, that we think it's related to the DLL size. However, when restarting Visual Studio 2008, the error vanishes. Until it appears later again, after a few rebuilds. The disk space is not a problem.

作为旁注,我们得到'意外错误写入元数据'错误,我们认为它与DLL大小有关。但是,重新启动Visual Studio 2008时,错误消失。直到它再次出现,经过几次重建之后。磁盘空间不是问题。

4 个解决方案

#1


7  

Yowser! Have you perchance got some huge resx files (or other embedded content) that are getting embedded in the dll? Perhaps treat those as external content? I'd start by looking at the files in the project tree... that 20Mb has to come from somewhere obvious - large graphics, etc.

Yowser!你有没有得到一些嵌入在dll中的巨大resx文件(或其他嵌入内容)?也许把那些当作外在内容?我首先看看项目树中的文件...... 20Mb必须来自显而易见的地方 - 大型图形等。

#2


2  

PE Explorer will show you the contents.

PE Explorer将显示内容。

This may also help?

这可能也有帮助吗?

Update: Dependency Walker may also help here. You can run it in "Profile Mode" which works by executing your application and watching it to see what it loads.

更新:Dependency Walker也可以在这里提供帮助。您可以在“配置文件模式”中运行它,它可以通过执行您的应用程序并观察它以查看它加载的内容来运行。

#3


0  

Microsoft.SharePoint.dll is 9Mb. Even for a complex product like SharePoint, DLLs are separated into separate projects.

Microsoft.SharePoint.dll是9Mb。即使对于像SharePoint这样的复杂产品,DLL也会分成单独的项目。

If you have a large project and that nothing is coming from the resources, might I suggest splitting your project into different assemblies?

如果您有一个大型项目并且没有任何资源来自资源,我是否可以建议将您的项目拆分为不同的程序集?

I saw the exact error you had but on a VS2003 environment (which Microsoft showed on support.microsoft.com). However, since you are in VS2008, it might also be due to a disk space issue.

我在VS2003环境中看到了确切的错误(Microsoft在support.microsoft.com上显示)。但是,由于您在VS2008中,它可能也是由于磁盘空间问题。

Did you verify that all the disks used by Visual Studio are not full/almost full?

您是否验证Visual Studio使用的所有磁盘都未满/几乎已满?

#4


0  

Oops! Found a bunch (50+) of huge report templates generated using Crystal Reports, each one around 1MB.

哎呀!找到了一堆(50+)使用Crystal Reports生成的大型报表模板,每个模板大约1MB。

All we had to do was excluding them from project.

我们所要做的就是将它们排除在项目之外。

#1


7  

Yowser! Have you perchance got some huge resx files (or other embedded content) that are getting embedded in the dll? Perhaps treat those as external content? I'd start by looking at the files in the project tree... that 20Mb has to come from somewhere obvious - large graphics, etc.

Yowser!你有没有得到一些嵌入在dll中的巨大resx文件(或其他嵌入内容)?也许把那些当作外在内容?我首先看看项目树中的文件...... 20Mb必须来自显而易见的地方 - 大型图形等。

#2


2  

PE Explorer will show you the contents.

PE Explorer将显示内容。

This may also help?

这可能也有帮助吗?

Update: Dependency Walker may also help here. You can run it in "Profile Mode" which works by executing your application and watching it to see what it loads.

更新:Dependency Walker也可以在这里提供帮助。您可以在“配置文件模式”中运行它,它可以通过执行您的应用程序并观察它以查看它加载的内容来运行。

#3


0  

Microsoft.SharePoint.dll is 9Mb. Even for a complex product like SharePoint, DLLs are separated into separate projects.

Microsoft.SharePoint.dll是9Mb。即使对于像SharePoint这样的复杂产品,DLL也会分成单独的项目。

If you have a large project and that nothing is coming from the resources, might I suggest splitting your project into different assemblies?

如果您有一个大型项目并且没有任何资源来自资源,我是否可以建议将您的项目拆分为不同的程序集?

I saw the exact error you had but on a VS2003 environment (which Microsoft showed on support.microsoft.com). However, since you are in VS2008, it might also be due to a disk space issue.

我在VS2003环境中看到了确切的错误(Microsoft在support.microsoft.com上显示)。但是,由于您在VS2008中,它可能也是由于磁盘空间问题。

Did you verify that all the disks used by Visual Studio are not full/almost full?

您是否验证Visual Studio使用的所有磁盘都未满/几乎已满?

#4


0  

Oops! Found a bunch (50+) of huge report templates generated using Crystal Reports, each one around 1MB.

哎呀!找到了一堆(50+)使用Crystal Reports生成的大型报表模板,每个模板大约1MB。

All we had to do was excluding them from project.

我们所要做的就是将它们排除在项目之外。