1

An old MFC application now rebuilt in Visual Studio 2015 Community which uses an old DLL, I'm trying (and tearing my hair) to determine exactly what runtime DLLs are required to properly run the application on machines which doesn't have VS installed.

Target OS is Windows 7. It's a 32 bit application.

The application uses a DLL MAuEASE_s.dll, which uses mfc80.dll and msvcr80.dll DLLs. I don't have the source code of MAuEASE_s.dll so I cannot rebuild/replace it.

On my development machine, the application runs fine with the following set of files put into the same folder:

  • main executable
  • MAuEASE_s.dll
  • mfc80.dll
  • msvcr80.dll
  • an ini file required to run the software

To test how it will behave in client machine, I'm using the same set of files on a fresh copy of Windows 7 on a virtual machine. The problem only appears to be specific to mfc/msvcr dependency of MAuEASE_s.dll.

On my machine, even though I've put the DLLs in executable's directory, they are picked from the following folder (found from Dependency Walker):

  • c:\windows\winsxs\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f\MFC80.DLL
  • c:\windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_d089f796442de10e\MSVCR80.DLL

I've copied exactly these two DLLs in executable's directory, then copied the directory into virtual machine running Windows 7. There, Dependency Walker shows error for MAuEASE_s.dll:

The side-by-side configuration information for MAuEASE_s.dll contains error.

Screenshot:

enter image description here

Interestingly, from the manifest of MAuEASE_s.dll I found that it needs 8.0.50727.4053 version of both of the DLLs. But the DLLs found in development machine's c:\windows\winsxs have versions 8.0.50727.6195 and 8.0.50727.6229 but these DLLs still work on development machine.

I've searched the Windows directory for version 8.0.50727.4053 of the DLLs and found them and replaced them in the application's executable directory. The application still works on the development machine.

None of these versions work in the virtual machine.

What's going on and how can I find the exact DLLs to run the application in a PC where Visual Studio is not installed?

2
  • Welcome to DLL hell. Thought that was history, but seems not.
    – kebs
    Jan 12, 2016 at 10:24
  • @kebs: It's not - thanks to legacy applications.
    – Donotalo
    Jan 12, 2016 at 10:31

3 Answers 3

3

My answer doesn't target the problem how to fix the WinSxS error. It just shows how you can force the system to load the application local MFC DLLs.

The MFC80. DLL belongs to VS-2005. They introduced loading DLLs for the MFC side by side. So the Manifest inside the DLL tells the loader to find a public version in the WinSxS directories.

Even if you don't have the source of the MAuEASE_s.dll you can change the behaviour just in changing the embedded manifest. It is just a XML block.

You can just open the DLL in VS and you can modify the resource there. (Export/Import it). Or use another tool to modify the resources of an executable (Resource Hacker etc.)

Long time ago I wrote an article to use the MFC DLL as a private assemblies in your application directory. You just need to remove one token from the manifest. See here.

Alternativly you can create a new manifest as described in the article and replace the existing one with mt.exe.

1

Binaries built with Visual Studio prior to Visual Studio 2010 referenced dependent DLLs through a manifest (embedded or external). Dependencies referenced through a manifest are searched for in the native side-by-side assembly cache (WinSxS folder) only. The application's directory is not searched. To verify, whether a binary contains an embedded manifest you can use the manifest tool Mt.exe:

mt.exe -inputresource:<filename of binary> -out:manifest.txt

To deploy an application that references DLLs through a manifest, or references DLLs that do, you should deploy those binaries using the respective vcredist_<architecture>.exe download.

If you would rather not have to install files into the native side-by-side assembly cache (because your installer should not need admin rights, for example), you would need to modify the binary (MAuEASE_s.dll in your case). To do so you can retrieve the original manifest first (see above), update the manifest by removing the respective assembly references, and replacing the original RT_MANIFEST resource (using a resource editor like Visual Studio, or Mt.exe):

mt.exe -manifest manifest_new.txt -outputresource:<filename of binary>

Once that's done, you can deploy the DLLs alongside the binary that references them. Note, that this no longer allows you to link against a specific version of a DLL.

0

As xMRi and IInspectable suggested, I was able to modify the manifest inside the DLL to force load the particular DLL I put in the executable's directory. But it didn't solve the problem. Whenever I was launching the application on the fresh PC, I got the following error:

The application was unable to start correctly (0xc0150002).

In my development machine, I had tons of Visual C++ redistributable versions installed and I found several versions of mfc80.dll and msvcr80.dll in Windows directory. I copied all possible combinations of these two files of different version one by one and tried to launch the application. But it didn't work.

What did work is (what I wanted to avoid) - I opened the uninstall program window from control panel. There I found 3 different versions of Visual C++ 2005 redistributables are installed:

  • 8.0.61001
  • 8.0.50727.42 (this is x64 version)
  • 8.0.56336

I started looking online for these installers. On the fresh PC I started installing the redistributables one by one and trying to launch the application. Finally I found that after installing version 8.0.61001, which is Visual C++ 2005 redistributable SP1 with MFC security update, the application successfully launched.

Now I'm going to pack the installer of this redistributable in my application's installer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.