简体   繁体   中英

How to minimize a ASP.NET C# project DLL size?

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?

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.

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.

PE Explorer will show you the contents.

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.

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

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.

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

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

All we had to do was excluding them from project.

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