3

Ok, I have an application that I have developed, let's call it Project A. Functions not found in the Microsoft .NET Framework I put into a shared library, let's call this MyLib.

Now Project B, C, D, E also uses MyLib (a lot of projects). My "MyLib" has been slowly added to for 4 or 5 years now.

Problem I now have is MyLib is huge. Well, 5MB, but I call that huge.

Question I have is should I, can I, and how can I compile my projects with MyLib but strip away non-used functions, classes, etc from MyLib? It rather blows that my Hello World apps, that use 1 tiny static function from MyLib results in a 6MB HelloWorld.exe (after ilmerge).

FOSS > Payware.

1
  • 1
    I don't think such a tool exist, but good luck. Common sense says either don't care about the size or split your classes into separate classes based on proximity
    – dr. evil
    Feb 27, 2011 at 16:33

4 Answers 4

3

What you are searching for is the Mono Linker and it's source code is on GitHub. The standalone tool isn't used often but as it's one step of their iPhone compiler i guess that the libs are rock-solid.

Because you don't always use every feature of the libraries you are using for your program. By using the linker, you can reduce the size of what you have to distribute to your users.

0
0

Its looks like you need to group you library functions into smaller sections. Rather than take your cumbersome swiss army knife. Just break it down in to smaller parts.

"Best practice" would be to cover your mylib with unit tests and slowly refactor those classes apart.

"Best Practice" would be split those up. Look at the .net framework. There is not one huge dot.dll

1
  • Problem with multiple assembilies like MyLib.Text.dll is more maintenance, and Visual Studio runs slower (because I like to add them as Projects so I can tweak the source easily). Are these really my only choices? Feb 27, 2011 at 16:31
0

AFAIK, there's only the painfull way: Split up your library into functional parts. This will mean going through the various projects that consume MyLib and add the appropriate new references, but I don't see an other way. And that's also the tricky part: Deciding the boundaries of those functional units. If you're not careful, you might end up with (i.e.) referencing 6 different assemblies, where there previously was only one, worsening things along the way.

Evaluate very careful what your projects use and don't use, before you go down this path.

0

Take some cues from the .Net framework itself. If MyLib has a lot of Text helper objects and functions along with a lot of say Web helper objects and functions split them into two separate projects and namespaces.

Of course, I only recommend this because it seems to bother you. Personally I have much bigger pet peeves than a few slightly oversized DLLs.

Since you say it's making VS run slower I assume you mean that you're including the project MyLib and not just the DLL. I would stop doing this immediately. Run a build of MyLib and simply include a reference to the DLL.

1
  • Ha ha, yeah I guess this is a minor question. I was hoping for a link to a tool like ilmerge, but called ilreduce or something. Problem with multiple assembilies like MyLib.Text.dll is more maintenance, and Visual Studio runs slower. Feb 27, 2011 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.