rtischer8277
Posts: 22
Joined: Fri Nov 30, 2012 2:26 pm

Installed dependency dlls not getting executed

My .exe has a dozen or so dependent dlls. Easy enough to add and I can see that they get properly installed on the target machine along side the .exe. I assumed that when AI runs the .exe the search order would be to use the dlls that I installed. But instead it still seems to be executing an out-of-date dll found in the Windows\system32 folder. How do I get the installed .exe to pick my also-installed dependent dlls?
rtischer8277
Posts: 22
Joined: Fri Nov 30, 2012 2:26 pm

Re: Installed dependency dlls not getting executed

I see two approaches to a solution:
1) Force and update for each dll. For example, the first offending dll is ws2_32.dll found in \Windows\System32. The target machine's is out of date. I could copy the new on in on top of that one.
Problems: this assumes the new dll is always backwards compatible. I don't know if that is the case. Also, the target user may reinstall, say, and older SDK that re-establishes the older dll and my new .exe won't run anymore.

2) prepend a new APPDIR environment variable.
This would presumably let my .exe pick up the dependent dlls which I have installed in the same dir.
Problem: how to prepend into existing target env var chain.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installed dependency dlls not getting executed

Hello,
1) Force and update for each dll. For example, the first offending dll is ws2_32.dll found in \Windows\System32. The target machine's is out of date. I could copy the new on in on top of that one.
Problems: this assumes the new dll is always backwards compatible. I don't know if that is the case. Also, the target user may reinstall, say, and older SDK that re-establishes the older dll and my new .exe won't run anymore.
I'm afraid that in order to achieve what you want, when your application is developed it should be configured to search the related dll relative to EXE. You can take a look on "Dynamic-Link Library Search Order (Windows)" article which may be useful for you.
2) prepend a new APPDIR environment variable.
This would presumably let my .exe pick up the dependent dlls which I have installed in the same dir.
Problem: how to prepend into existing target env var chain.
In order to achieve this you can add, for an environment variable, a prepend operation when existing on our "Environment Variables" page. Also, please keep in mind that the environment variables list will be updated only after the installation process is finished. So, if your application will be launched on ExitDialog, then in that moment the environment variable is not up to date.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rtischer8277
Posts: 22
Joined: Fri Nov 30, 2012 2:26 pm

Re: Installed dependency dlls not getting executed

You point out that 2) will not work because I am using ExitDialog to launch the .exe.
when your application is developed it should be configured to search the related dll relative to EXE
Could you explain this a little more? What is the result of "searching the related dll"? Time and date? Functions it contains? For example, on the particular target machine I installed my .exe on, the old WS2_32.dll the function GetHostNameW was not found in the 11/20/2010 WS2_32.dll. I think either I replace the entire dll if the dates differ or not. But that leads to the problem, as I have already stated, that if the target machine user reinstalls the old version, then my .exe will not run. Maybe this is not a valid concern. The other objection I had was that this approach assumes the installed dll is backwards compatible. Is this a reasonably safe assumption? Is 7/20/2012 WS2_32.dll backwards compatible with WS2_32.dll 11/20/2010? I would assume so. Does anyone know whether this is a consistent policy or not?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Installed dependency dlls not getting executed

The problem is not with the dates, it is a simple OS limitation. What happens is that the installer process that writes to the environment variables list, loads the variables from the system when started, without your new variable. When this process launches the application at the end, it also passes to it its list of environment variables, which does not contain your updated variable.

Best regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rtischer8277
Posts: 22
Joined: Fri Nov 30, 2012 2:26 pm

Re: Installed dependency dlls not getting executed

So altering the environment variables won't work. Then let's concentrate on running the .exe with the appropriate dependent .dlls. The installer copies all the dependent .dlls into APPDIR where the .exe is installed, but they are not being used. Why is this? Is it because the .msi is copied into a temporary folder somewhere and being run from there?

Also, I tried checking 'Visual C++ Redistributable for Visual Studio 2012' which is the compiler I am using. The target machine gave me the same error (GetHostNameW not found in WS2_32.dll).
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installed dependency dlls not getting executed

Hello,
So altering the environment variables won't work. Then let's concentrate on running the .exe with the appropriate dependent .dlls. The installer copies all the dependent .dlls into APPDIR where the .exe is installed, but they are not being used. Why is this?
Unfortunately, this problem is caused by your application design. You should search an answer for this issue on development forums (e.g. http://stackoverflow.com). Also, you can take a look on "How can I tell the exe to use the local DLL instead of the registered one?" article.
Is it because the .msi is copied into a temporary folder somewhere and being run from there?
No, I'm afraid this is not related to the MSI installation.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”