5

I am developing a small library that will be used across multiple applications. I would like to use some third-party libraries within my own library (e.g. log4Net, Entity Framework, etc.). I would imagine I can either deploy the DLLs alongside my own library, or use ILMerge to create a single DLL (I know little about ILMerge having never tried it).

I'm concerned about what will happen if the applications that consume my library also use the same third party libraries that I will be using. For example, if I use log4Net version 1.2, and a consuming app uses log4Net version 1.0, will I get a conflict of some sort, or will only one version of the assembly not load?

Does ILMerge prevent this? How is this typically resolved when developing a library with 3rd party dependencies?

Phil Sandler
  • 27,544
  • 21
  • 86
  • 147
  • I've run into this situation before - it was a typical huge corporate created monstrosity with a huge number of projects. At one point, someone added a project with a much newer version of log4Net that was needed for it, and it broke everything. The solution at the time (which I thankfully wasn't involved in) was to change code as needed to be able to have all the projects reference the same newer version of log4Net. I'd love to see a good solution for this sort of issue, besides "install it in the GAC and reference your particular version". – Gjeltema Jun 07 '13 at 22:38
  • Hans, can you clarify you comment? I don't know where my question implies a system doesn't need maintenance, or that a project is ever done. – Phil Sandler Jun 08 '13 at 02:48
  • 1
    @HansPassant I'm confused too - were you intending to write that response to another question? It seems out of place with this question. – Gjeltema Jun 08 '13 at 03:12

2 Answers2

3

You may use the extern alias:

You might have to reference two versions of assemblies that have the same fully-qualified type names. For example, you might have to use two or more versions of an assembly in the same application. By using an external assembly alias, the namespaces from each assembly can be wrapped inside root-level namespaces named by the alias, which enables them to be used in the same file.

Here's a Extern alias walkthrough.

Alex Filipovici
  • 31,789
  • 6
  • 54
  • 78
0

The best way would be to deploy alongside your app. NuGet manages these sort of dependencies very well. Unless you have some specific reason to use ILMerge, it'll just make your life harder - perhaps you want to upgrade, for example.

Simon Halsey
  • 5,459
  • 1
  • 21
  • 32