1

I have a fairly large project in Visual Studio 2010

I can build the project in both Debug and Release mode, copy the generated exe file along with a custom dll I need for a function in the program to another computer, and the exe file works without any problems

I am trying to make an installer for this project in Visual Studio 2010, following the instructions here: https://www.technical-recipes.com/2011/how-to-create-an-installer-in-microsoft-visual-studio/

I do not get any errors while building the installer, and I get a setup.exe and an msi file as a result, but if I install my program in another computer (not by development machine), when I try to run my program after installation I get a missing api-ms-win-crt-runtime-l1-1-0.dll error

How do I debug this problem? Since I can simply copy my Release or Debug build to the computer and make it work, doesn't it mean all the dll files my program is dependent on already exists in the other computer? And if this already works, why isn't the installer version working? How do I make sure that everything I need for this program is included in the installer?

My project in MFC dialog based and uses one third party library, for which I have both .lib and .dll file available. I need to do this in Visual Studio 2010. My development machine is Windows 10 64 bit Home edition version 1909. The installer I currently create installs my program in Program Files (x86) folder.

user13267
  • 6,871
  • 28
  • 80
  • 138

1 Answers1

1

Static Linking MFC: It appears this issue was solved by making sure to statically link to MFC libraries. In the VC++ project: enable the setting: "include MFC in a static library". This enables static linking of MFC components, eliminating the dependency on shared dlls.

This is a common "missing runtime error" - there are generic check lists below which include this as one source for application launch problems.

MFC

Warning: Generally static linking should be avoided in order to benefit from security updates to shared dll files via other update mechanisms.


Short Version: In Visual Studio Installer Projects, check if the Visual C++ Runtime is available in the Prerequisites list.

See this answer, here is a quick screen shot:

VC++ Runtime


Tools: If your project is large you might want to consider another MSI tool. There are many limitations with Visual Studio Installer Projects.

Merge Modules: There are merge modules to install the Visual Studio C++ Runtime, but it is recommended to use the setup.exe for these reasons.


Visual C/C++ Runtime: You are probably just missing the Visual Studio C/C++ Runtime. It needs to be deployed with your application, it is not on there by default (unless you link statically, in which case it should not be needed). Skim this list quickly for other ideas.

You can download the VC++ redistributables at ("The latest supported Visual C++ downloads"):

More Information:


Secondary Links:

Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Thank you. I will check out your links. I have one question though. Since I can simply copy my Release build .exe file to this computer and it works, doesn't that mean the Release build already incorporates everything I need to run inside inside the Release build's .exe itself, and that my visual studio version is capable of making such an exe file? What is different when I build an installer? – user13267 Apr 14 '20 at 00:08
  • One more question if you don't mind. The installer I made copied my program's .exe file and a few dll's, but it didn't make an uninstall.exe. I have read this (https://stackoverflow.com/questions/1218397/how-to-create-uninstaller-in-visual-studio-setup-project) and apparently uninstalling is easy just using the msi file or through the add/remove programs list, but I would like to have an uninstall.exe as well if possible. Is there a way to make Visual Studio 2010 generate the uninstall.exe as well? – user13267 Apr 14 '20 at 00:36
  • ***Uninstall.exe***: Uninstall.exe is considered an "anti-pattern" and you should not include it in your package. Uninstall is easy from the control panel or via command line or even a batch file. [MSI Uninstall](https://stackoverflow.com/a/1055933/129130). – Stein Åsmul Apr 14 '20 at 00:55
  • ***Manifest***: If the file runs without the installer the question is if you need a manifest installed along with it? Maybe it is the opposite? A manifest that is wrong is included with the setup? Try removing it. Do a file-diff on the manually created folder and the deployed one and see what comes up. – Stein Åsmul Apr 14 '20 at 00:56
  • I don't have a manifest file in my project. I selected runtime libraries (both x86/64 versions) in the prerequisites window and selected "Download prerequisits from the same location as my application" option. Now after the build I get folders with vcredist_x86/64.exe. I still get the same dll file is missing error after install on my test machine. I then replaced the runtime library installers with the latest downloaded from Microsoft website in your link, and I am still getting the same dll error. What could be the problem here? – user13267 Apr 14 '20 at 02:47
  • My test machine is Windows 10 64 bit English version (it is probably a Korean version with system language changed to English) and my test machine is a Windows 8 64 bit Korean version. I have tried installing both 64 and 32 bit versions of the Visual C++ 2010 runtime libraries and I am getting the same errors. Could this be somehow related to the Windows version and language? Is this something I need to be worried about? I need this to run on at least Windows 7 and later, and on any language versions. – user13267 Apr 14 '20 at 02:51
  • Got to go now, but you can [do a quick Procmon.exe session](https://stackoverflow.com/a/51940598/129130) to see what is going on. **This must be something trivial**. Too tired, but I just link to: [check list 1](https://stackoverflow.com/a/53530377/129130) and [check list 2](https://stackoverflow.com/a/49637913/129130). And finally ["Express Failure to Launch Debugging" check list here](https://stackoverflow.com/a/25005864/129130) (search for it - or find it down the page). Finally - launch the EXE itself, and not the shortcut on all boxes. – Stein Åsmul Apr 14 '20 at 03:37
  • I managed to fix the problem. Thanks for your help. I always launch the exe itself, but my problem was that I had to exclude some dll files from the installer's build project in Visual Studio 2010. When I created the installer build it automatically added dll files to the build as dependencies, based on the lib files that I had attached to my main project. It turns out I had to exclude these dll's from the installer build in the Visual Studio IDE – user13267 Apr 14 '20 at 10:04
  • In fact, it's working even without Visual Studio 2010 redistributable – user13267 Apr 14 '20 at 10:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/211635/discussion-between-stein-asmul-and-user13267). – Stein Åsmul Apr 14 '20 at 12:57