views:

491

answers:

3

Duplicate - this exact question was asked here - the only solution seems to be post build event.

In Visual studio 2008, I have the following projects:

  • A - references B

  • B - references Lib.dll

When B is built, Lib.dll appears in B/bin/Debug. (this is ok)

When A is built, B.dll appears in A/bin/Debug, but Lib.dll does NOT appear in A/bin/Debug.

Wouldn't it be logical behavior to copy also all B's dependencies to output path of A, since B will need these assemblies at run-time?

All references have copylocal = true.


(Now I have to reference all B's dependencies from A by hand, is that correct? I could also use a custom build step I guess. Anyway, does this behavior have any advantages/sense?)

A: 

I have done the same procedure many times and it is not necessary to re reference assemblies manually. One easy way to test this is:

  1. reference B in A
  2. Create an instance of an object from B in A.
  3. Compile.

If the build completes successfully, everything is referenced OK.

Igor Zelaya
The build completes successfully, but at runtime the instatiation of object from B in A ends up by exception "Cannot load type or assembly", because that object from B uses objects from Lib.dll, which is neither in GAC or current folder.
Martin Konicek
A: 

If Lib.dll is an interop dll then its underlying dll won't be copied. Other than that I'd say there's probably operator error because you definitely don't need to manually reference dependent managed assemblies.

Arnshea
A: 

This only works if the assembly is actually referenced by the .dll. i.e. If you have LibInterface.dll and LibImplementation.dll - and your code in A only references the classes in LibInterface.dll, there is no way to get LibImplentation.dll into the output for B (cleanly).

This also applies for any arbitary files - i.e. if you have Randon.myFile that is related to project A, this would be the desired procedure: 1. Add as copy local, or build event to project A (so turns up in output for project A) 2. In Project B, set "copy local" on project A ref. 3. You should then get everything in the output of project A in project B (including your file) - but you don't.

There could be some other option - "Copy Local - all" or something. This would help VS support IOC techniques, and clean abstractions.

Ian