简体   繁体   中英

Referenced DLL in VisualStudio can't find its own DLL C#

I'm using an external DLL to handle PDF exports in a C# project. I've added the external DLL reference in Visual Studio, added appropriate using statements, Intellisense shows all sorts of methods and properties when I type out the namespace, and the same is reflected in the object explorer.

However, when I run the application, the program throws a run-time exception because my external DLL can't find another DLL that lives in the same directory as the external DLL.

To make matters more confusing, the program doesn't complain if I just copy every single DLL from the directory of the one I want to reference into the Debug folder of my program, but obviously I shouldn't have to do this.

Thanks in advance.

What you need is to check "copy to output directory", "always copy" in the properties of your DLL in VS. Otherwise the DLL is not automatically copied in the output, and the program can not run.

I think this other question might help you: MSBuild doesn't copy references (DLL files) if using project dependencies in solution

Looks like your dependency has another reference you want to include into your drop. You have two options: - Either add a reference to that implicit dependency as well (and set "Copy Local" = true) or - Add the dependent dll as a project item and mark it as "Copy to output directory" = true.

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