Incorporate Multiple DLLs from One Reference?

  • Thread starter Thread starter Mark Olbert
  • Start date Start date
M

Mark Olbert

I'm developing a set of libraries under the NET framework using C#. Certain of those library
assemblies rely on other library assemblies. Schematically:

Library A
references Utility Library 1
references Utility Library 2

When I include a reference to Library A in an application, I can access the methods of Library A,
but anything in Library A that depends on Utility Libraries 1 or 2 fails. This is apparently because
the application does not have references to either Utility Library 1 or Utility Library 2.

I can solve this problem by manually adding references in the application to Utility Libraries 1 and
2. However, I'd like to arrange things so that adding a Library A reference to any project
automatically adds references to Utility Libraries 1 and 2.

How do I do this? I'm pretty sure it can be done, because I've noticed that adding a reference to,
say, the Microsoft Excel object library actually causes several "extra" references to be added
automatically (e.g., to stdole, and to some VB library).

Thanx in advance for any help/advice!

- Mark
 
Its not about adding references per se, that just solves the situation in VS.NET. The issue is that when the application runs it needs to be able to find all subordinate DLLs (or more accurately, assemblies). Adding the reference meant "Copy Local" was turnd on by default and sdo all the assemblies were copied to the same directory as the executable.

To make this work you need to make sure the subordinate assemblies are copied to the executable directory or give them a strong name and put them in the GAC. OK there are other options but it is mainily around whether those assemblies are unique tothe application (put in the exe directory or a configurable subdirectory) or are shared amongst applications (put them in the GAC there are other options but lets get an idea of your requirements first)

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

I'm developing a set of libraries under the NET framework using C#. Certain of those library
assemblies rely on other library assemblies. Schematically:

Library A
references Utility Library 1
references Utility Library 2

When I include a reference to Library A in an application, I can access the methods of Library A,
but anything in Library A that depends on Utility Libraries 1 or 2 fails. This is apparently because
the application does not have references to either Utility Library 1 or Utility Library 2.

I can solve this problem by manually adding references in the application to Utility Libraries 1 and
2. However, I'd like to arrange things so that adding a Library A reference to any project
automatically adds references to Utility Libraries 1 and 2.

How do I do this? I'm pretty sure it can be done, because I've noticed that adding a reference to,
say, the Microsoft Excel object library actually causes several "extra" references to be added
automatically (e.g., to stdole, and to some VB library).

Thanx in advance for any help/advice!

- Mark
 
Richard,

I'm not quite sure I'm following you, but what I'd like to do is have all of the subordinate
assemblies get copied to the executable's bin directory. They're not large, but they're also not
something I'd like to have in the GAC.

So how do I do that?

- Mark
 
well, as you know, you've got to add them to the project reference.
it's not big deal hey!

that doesn't mean you code need them directly to work, that just means your
application need them all in the same spot (directory)
 
Actually, Lloyd, it is a big deal, because I don't want to have to explain to my customers that when
they add one reference, they really must add three. By hand. They'll forget, and then some of them
will get upset with me, and I'll lose business.

- Mark
 
hey, don't take it badly :)
btw you just tell us more information here.
you write a dll for customer, these customer should reference it.

most third-parties solve this problem by installing their lib in the GAC,
granted I don't like this approach much either.

anyway I see 3 possible solution:
1. explain to your customer they need to add all the related library which
are: "1, 2, 3"
(if you explain it very clearly, I'm sure they would understand)
2. install your dependancy in the GAC
3. you might be able to play with assembly linker (al), the disambler,
etc...
(or maybe write something your self), extract code module from your related
assembly and inject them into your assembly (llok for the documentation of
'al.exe')
 
But how does Microsoft do it? When I add a reference to a COM library (e.g., Word 10), multiple
references get installed. Yet the initial reference is to a single file.

So how does that work?
 
Back
Top