Search code examples
c#dllvisual-studio-2012dll-reference

VS2012 dll file not found at run time


I have a project that references a dll file. I simply added a reference by right clicking on the properties, selected add reference, and browsed for the dll. Intellisense recognizes the library and all it's classes/methods but when I run it I get this.

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in program.exe

Additional information: Could not load file or assembly 'Api.dll' or one of its dependencies. The specified module could not be found.

The file appears in the bin folder and is still at the location I browsed too. The program runs without errors if I don't use any classes or methods. The library doesn't have any dependencies I'm aware of.

Edit: found a lot of missing dependent DLL files using dependency walker that I thought were causing the problem. After putting all the dependent DLL's in the same folder and referencing it the problem persists


Solution

  • Turns out that even once I found the missing DLL's using dependency walker that they weren't being imported into my project with the original DLL. Moving them into the bin/debug folder fixed the error