Reputation: 53
I am working on a C# .NET project in Visual Studio 2010. I am integrating a hardware peripheral that has a DLL. I reference the DLL file in my project and the code compiles/builds without any errors. When I run my application I get a runtime error saying that it is looking for another DLL file. It appears that the DLL I reference in my project has 42 other DLLs that it depends on. When I place these 42 DLLs in the output directory (bin/debug) the application runs just fine.
My questions is this: what is the best way to manage these extra DLL files when Visual Studio doesn't recognize them as dependent libraries?
Upvotes: 5
Views: 2408
Reputation: 28325
This scenario does resemble a lot to deploying SQL Server Compact files. In that context it's called Private File–Based Deployment
.
It also requires some external (unmanaged) DLLs that the application will depend on.
What it boils down to is to include the DLLs in your project and set their Copy to Output Directory
properties to Copy if newer
. They will then be copied to the destination folder after a successful build.
EDIT:
Based on your comment, it seems to you are having problems at install time of you application (something you completely fail to mention in your question), and you have written a Custom Action
for your installer to copy these 42 DLLs to your target.
There's no need for a CA to do that. Simply right click on your installer project -> View ->File System.
Select the Application Folder
, in the right hand side right click and select Add File
and add your 42 DLLs.
Upvotes: 6
Reputation: 319
If you mean to manage these files at compile-time you can add a post-build event to the project to copy all of the necessary files over to the output directory. Add flags to xcopy here to only copy over if changed.
If you mean at run-time an installer would be your best solution.
Upvotes: 2
Reputation: 13229
You should work on creating an Installer package, almost all Installers will bring in all of the dependencies of referenced dll's if the projects outputs are configured as needed for the installer. It is the only way I can think of to dynamically have your non-referenced dependencies be automatically brought in.
Upvotes: 0
Reputation: 575
Or you could combine them using something like ILMerge to combine the assemblies. And you just add a reference to the resulting assembly.
How to merge multiple assemblies into one?
Upvotes: 1