Dependent DLL is not getting copied to the build output folder in Visual Studio

I found that if ProjectX referenced the abc.dll but didn’t directly use any of the types DEFINED in abc.dll, then abc.dll would NOT be copied to the main output folder. (It would be copied to the ProjectX output folder, to make it extra-confusing.)

So, if you’re not explicitly using any of the types from abc.dll anywhere in ProjectX, then put a dummy declaration somewhere in one of the files in ProjectX.

AbcDll.AnyClass dummy006; // this will be enough to cause the DLL to be copied

You don’t need to do this for every class — just once will be enough to make the DLL copy and everything work as expected.

Addendum: Note that this may work for debug mode, but NOT for release. See @nvirth’s answer for details.

Leave a Comment

tech