简体   繁体   中英

DLL reference not copying into project bin

Project A references Project B , and Project B references an external DDL (restored using NuGet). The DLL should get copied into Project A 's bin folder (along with Project B 's DLL):

DLL引用复制到Bin

In my case, when running Project A , I get the following exception thrown:

Could not load file or assembly 'PostSharp, Version=3.2.18.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' or one of its dependencies. The system cannot find the file specified.

The DLL is not being copied into Project A 's bin. All other external references from Project B are being copied across just fine, which is what is confusing for me.

Copy Local is set to true for all references involved. Example:

复制本地参考

How do I do this?

Note: Using Visual Studio 2013.

The options that I found were to:

  • Add a reference to PostSharp in Project A.
  • Add dummy code in Project B so that the compiler would detect that the reference is being used.
  • Add a build event to force copy the DLL.

I don't like any of the above solutions. They are hacks in my opinion and will only make for a more unmaintainable solution in the long run.

I have fixed the problem by using a common output directory. This seems to be a recommended solution by many. I have also experienced much faster build times. See this Stackoverflow post .

当我遇到这个问题时,这是因为我更改了项目的名称,但没有更改程序集名称 - 它与解决方案中另一个项目的程序集名称相同。

I've added some dummy (unused) code on Project B, making reference to the DLL needed.

Thus, the compiler will guess that it must copy the DLL into project A output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM