1

I have about 20 solutions with 5-10 projects each and they reference each other and some 3rd party libraries as well. I have an Output folder, were all of them are built. So I don't want to have any copies of each assembly that is being referenced (that's what the requirements are). So I've set the Copy local to false for every reference in one of the projects and it didn't throw an error at compile time. But at run-time it threw FileNotFoundException, saying "Could not load file or assembly 'X' or one of its dependencies. The system cannot find the file specified." As I've read in this and this thread, you could specify the paths for the CLR to search, but they have to be sub folders of the application base folder, and since I have 10 windows services, that means that I'll have to copy the referenced assemblies in each service's base folder (which is not the point).

One thing I've noticed is that when project A has a reference to project B, not only B.dll is being copied, but also C.dll (being referenced from B), D.dll etc. And the strange thing is when I set Copy local to false for reference B and I delete the copy of B.dll there is no problem - it manages to find it in the Output directory, but when I delete the copy of C.dll (or D.dll) that's when the problem occurs. So I set Copy local to false for the C reference in project B, but it didn't help.

Does anybody have and idea why is this happening?

Community
  • 1
  • 1

1 Answers1

2

You have to either:

  • Save them in the GAC, so every app can find the referenced assemblies;
  • Implement an event handler for AppDomain.AssemblyResolve to find the assemblies yourself;
  • Copy all assemblies in the build script to the right folders, or use one central folder.
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • as far as I've read, it's not a good idea to save the app libraries in the GAC. I didn't quite understand your third suggestion: - "Copy all assemblies in the build script to the right folders" - this means copies of one dll to numerous folders, which I'm trying to avoid. "or use one central folder" - I have an Output folder, where I build all the libraries. – Miroslav Georgiev Jun 02 '14 at 09:56
  • Well, there are three options. Pick the one that suits you best. You can use Visual Studio build scripts to do post-build actions, like simple copy commands. – Patrick Hofman Nov 24 '14 at 07:57