tags:

views:

213

answers:

5

I am trying to using PDF Library ITextSharp, in my project. ITextSharp has so many features, i am not using even 5% of it. I am just wondering, why i should ship the complete dll file, when i use only 5% of it.

Is there any way to statically link the library to my project and remove all unused methods,features from the library ?

+1  A: 

Without modifying the source code and building your own .dll, no there is no way to not ship the entire thing. Additionally, if you wanted to head the route of creating your own modified .dll, please be aware of any possible licensing issues involved (I don't know if there are any, but it's certainly something you should be aware of). And finally, I would add, I don't know how big the iTextSharp .dll is, but really ask yourself if however much space it takes up actually matters.

Timothy Carter
+2  A: 
  1. There is no benefit of static linking with .NET dlls.
  2. Its not easy to judge that you are using only 5% of the library, library may be using so much of internal code inside it to do lots of small small things that may not be seen by naked eye.
  3. However iTextSharp is open source, you can create striped down version of iTextSharp to ship with your project.
  4. By the way iTextSharp is smaller quite compared to earlier dlls required on non .net days.
Akash Kava
I beg to differ on point 1 as a single file deliverable has a number of advantages.
BCS
A: 

In this type of situation, your best bet is the site where you downloaded the code.

In many cases they use conditional compilation to include/exclude certain pieces. If the code isn't written with conditional compilation in mind, it will be "difficult" to do it yourself.

I personally would not recompile the source, unless there is a bug that needs to be fixed and you cannot wait for a new release. The time spent on the changes is time lost on your main project (the one you're getting paid for).

Brad Bruce
+1  A: 

If you want to reduce the size you have two options an obfuscator or an assembly compressor.

I haven't used any obfuscator for .Net just for Java so I can't recommend you any but they do what you pretend: remove unused methods and classes.

Or you can create a single compressed executable with all the needed assemblies that is auto decompressed when started like the popular Aspack and UPX do for windows executables http://en.wikipedia.org/wiki/Executable_compression . I have tried .NetZ and was happy with the results.

rjlopes
+2  A: 

Disclaimer: I work for the company whose product I'm going to mention. I do know that other tools can do this as well but I only have direct experience with this one.

It is not necessary to modify any of the ITextSharp source or to perform your own custom build. It is possible to achieve all that you need with just the assemblies in your bin directory.

You can use Dotfuscator (the Removal option) to perform static analysis of the entirety of your application and output an assembly that only contains code that is actually used in your app. In addition you can use the Linking feature to link the DLL into your exe so that you are only shipping one file to the customer. This can result in a significantly smaller application footprint. You can take advantage of all of this functionality even if you choose not to use the obfuscation features that make you application harder to crack and reverse engineer.

Dotfuscator can be added into your build process in a number of ways, we integrate directly into Visual Studio (versions 2002 through 2010) so that you can just build your solution, there is also an MSBuild task for using on a Team Build server (if you choose not to have the build server build your solution), as well as a command line version for any other build system.

Dotfuscator will work on any .NET assembly type from including Silverlight assemblies.

These features are only available in the Pro version of Dotfuscator, if you contact PreEmptive Solutions we can set you up with a free, time limited evaluation so you can see how the product works for you.

If you just want to perform linking of assemblies there is also the ILMerge utility from Microsoft Research that will link multiple .NET assemblies into a single assembly.

Joe Kuemerle
+1 for a relevant and comprehensive answer, despite the possibility of conflict of interest.
Steven Sudit
Because he pointed it out, I don't think there is a conflict of interest. Or much of anything to conflict with for that matter.
BCS