2

I have Visual Studio 2015 installed, and I've built a .NET 4.6 application which depends on some third-party .NET assemblies, which depend on some C++ DLLs and EXEs, which in turn depend on the Visual C++ 2012 x64 Redistributable. The SDK I'm using includes some merge modules which deploy the SDK's .NET and C++ assemblies that I depend on (but not the Visual C++ runtimes).

If the Visual C++ 2012 redistributable isn't installed on a target machine, my .NET 4.6 app crashes on startup, saying Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'MyManagedDependency.dll' or one of its dependencies. The specified module could not be found. This occurs even when I have the Visual C++ 2015 redistributables installed on the target system. So it appears that the C++ runtime dependency isn't backwards/forwards compatible.

I'm using a Visual Studio 2015 Setup Project to create the installer for my application. However, the list of installer Prerequisites I can select from doesn't include the Visual C++ 2012 Runtime Libraries. The only Visual C++ libraries I can select as setup project pre-requisites are the 'Visual C++ "14" Runtime Libraries'. I believe these are the same thing as the Visual C++ 2015 Redistributable, which isn't sufficient for my software to load.

Is there any way to add the Visual C++ 2012 runtime to the pre-requisite list for my VS2015 Setup Project installer (for example, by installing more SDKs)? Or is there another way I should be packaging the 2012 C++ runtime in my installer?

EDIT: Digging through the documentation & installer package of the third-party SDK I'm using, it looks like my application might actually only run correctly if both the Visual C++ 2010 and 2012 redistributables are present on the target system. Also I might need to install both the x86 and x64 versions. I don't think I can install all of those with merge modules since this page says:

We recommend that you not use merge modules except when you don't have to service your application and you don't have dependencies on more than one version of the DLLs. Merge modules for different versions of the same DLL cannot be included in one installer, and merge modules make it difficult to service DLLs independently of your application. Instead, we recommend that you install a Visual C++ Redistributable Package.

How can I add these older redistributables as pre-requisites for my VS2015 Setup Project?

Hydrargyrum
  • 3,378
  • 4
  • 27
  • 41
  • Perhaps I haven't communicated clearly because I'm not a C++ or Windows installer expert. Installing the SDK does correctly install the runtime pre-requisites on the developer's machine, as part of the SDK's installer. I want to distribute my application, which *uses* the SDK, without requiring the SDK itself to be installed on the end-user's machine. So all I need is for the C++ runtimes to be pre-requisites for my own installer package (along with the merge modules that I already have set up). I'm not sure why this wouldn't be possible to achieve with VS 2015 Setup Projects? – Hydrargyrum Sep 23 '16 at 11:24
  • I'm not sure either, you just have to copy the DLLs into your install directory. Shouldn't take more than msvcr100.dll and msvcr110.dll but if you can't figure out what other DLLs you need then ask the SDK author. – Hans Passant Sep 23 '16 at 11:32
  • My earlier searches must not have had the right keywords. This looks relevant: http://stackoverflow.com/questions/15619728/vs2010-setup-project-with-c-2008-redistributables – Hydrargyrum Sep 23 '16 at 11:33
  • Well, those custom bootstrapper instructions from VS2010 need considerable updating for VS2015. The bootstrapper SDK is in a completely different location. If I can figure it out I guess I'll post a solution to my own question (unless it's closed first). – Hydrargyrum Sep 23 '16 at 11:46
  • Also http://stackoverflow.com/questions/29471775/where-is-the-vc-2012-runtime-bootstrapper-package-in-visual-studio-2013, http://stackoverflow.com/questions/21416169/visual-c-runtime-distributable-2010-in-visual-studio-2012 are analogous. Again, the solution presented there is not usable as-is due to changes in Visual Studio's file layout. – Hydrargyrum Sep 23 '16 at 12:03

1 Answers1

1

Several hours of research later, I've found that it's certainly possible to add items to the Visual Studio 2015 Setup Project Prerequisites dialogue box.

Combining this answer with VS2015's updated Bootstrapper path (\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages) from this MSDN article would achieve that goal.

However, that would leave me with a setup project that would only build properly in a fairly heavily customized build environment, which would be tricky to reproduce on new machines. I have found no simple-to-install VS add-on or MS package which would add this support.

In the end, the approach I'm now taking is to add the following MS merge modules to my setup project:

  • Microsoft_VC110_CRT_x86.msm
  • Microsoft_VC110_CRT_x64.msm
  • Microsoft_VC120_CRT_x86.msm
  • Microsoft_VC120_CRT_x64.msm

This results in the runtime DLLs getting deployed to C:\Windows\System32 and C:\Windows\SysWOW64, and they seem to work. This does not result in the Redistributable appearing in the Windows "Programs and Features" dialogue.

However, since MS recommends against this method of deploying the runtimes, I'm open to any easier-to-maintain method for packaging the "true" VC++ 2010 and VC++ 2012 Redistributable with my VS2015 Setup Project.

Community
  • 1
  • 1
Hydrargyrum
  • 3,378
  • 4
  • 27
  • 41
  • Hi, have you found any way to properly deploy the runtimes? I am facing the same problem currently and also would like to do it the proper way if possible. – user3696412 Feb 08 '21 at 09:55