Deployment and Dependencies
The deployment tools in Visual Studio automatically detect dependencies and add them to the deployment project whenever a project output group, assembly, or merge module is added to the project. There are, however, some cases where dependencies cannot be detected.
Rather than adding assemblies directly to a deployment project, it is best to add a project output group that contains the assembly. The deployment tools can more easily detect dependencies for a project output group.
For assemblies, all dependencies on other assemblies are detected. If, however, the assembly references an unmanaged component (for example, a COM .dll), any dependencies of that component will not be detected. Likewise, files added directly to a deployment project may have dependencies that are not detected. In either case, the dependent files are usually necessary for the application to run, but they will not keep the installer from running.
In order to prevent this problem, you must first determine what type of dependencies you have and take the appropriate action:
You may be referencing a component that may only be installed as part of another product — for example, the Web Browser control (shdocvw.dll), which is installed as a part of Internet Explorer.
In this case, you will need to exclude the component from the deployment project and you should add a launch condition that checks for the component on the target computer and prevents the installation if not found. The end user will need to install the product that provides the component before installing your application.
You may be adding an unmanaged component that does not expose all of its dependencies — for example, Microsoft Foundation Classes (MFC), which does not include localized satellite files as dependencies.
In this case, you will need to determine all of the possible dependencies and include them in the deployment project. You should check the documentation for the component or contact the component's author to get a list of dependencies.
Most dependency-checking tools, such as Depends.exe, will only find early-bound dependencies; late-bound dependencies will only appear at run time.
You may be referencing an assembly that has a dependency on an unmanaged component — for example, System.Data.dll, which has a dependency on Microsoft Data Access Components (MDAC) version 2.8. For more information, see How to: Add a Launch Condition for Microsoft Data Access Components.
To ensure that all dependent files are installed, you can add a merge module that contains the component and its dependencies. You may need to contact the author of the component to see if a merge module is available. For many Microsoft components, merge modules are available on the Microsoft Web site.
If a merge module is not available, you may want to add a launch condition to check for the component during installation and prevent installation if it is not found.