5

I have a program written in QT that works just fine. However it has an indirect dependency on dnssd.dll since a dll loaded by the program uses bonjour. If bonjour is not installed on the machine running the program it will say

The program can't start because dnssd.dll is missing from your computer. Try reinstalling the program to fix the problem.

I'm not loading this dll via LoadLibrary or otherwise. I linked the binary against the stub so it's loaded automatically before int main.

Obviously reinstalling the program does not fix the problem. For me it clearly says I need to install bonjour, but for most users this is extremly cryptic.

I would rather have this error message be something more informative such as "Bonjour needs to be installed for this application to work properly, go to [insert-url-here] to download it."

Is there a way to detect when a dll fails to load loke this and give a better error message?

vidstige
  • 12,492
  • 9
  • 66
  • 110
  • 2
    Why don't you package Bonjour in the installer (can't say how without knowing what kind of installer you're using), or something similar? – R. Martinho Fernandes Oct 12 '11 at 12:41
  • 1
    Nice idea. People tend to uninstall it since they don't know what it is. Also it's a hassle and will create a more complicated and fragile installer. It has to take to accound bonjour is already installed, etc. – vidstige Oct 12 '11 at 12:44
  • 1
    So, you prefer a more complicated and fragile application instead? Good installer frameworks provide robust solutions for most of these problems. This is not an unsolved problem. – R. Martinho Fernandes Oct 12 '11 at 12:45
  • @R.MartinhoFernandes yes I do. My experience with installers is to keep it as simple as possible. Installers are very hard to test and should basically just copy the files to a folder. This is pretty much how Android does it and the Windows 8 store also, and a install virtually never fails there. We in the windows desktop world have lot to learn from this. – vidstige Oct 01 '14 at 18:02

1 Answers1

5

Set it to delay load, then as early as possible (before you cause loading to happen), try to load it yourself (with LoadLibrary) and report the problem.

http://msdn.microsoft.com/en-us/library/151kt790.aspx

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • so basically you're saying there is no way to detect when a dll that was linked against a stub fails to load? – vidstige Oct 13 '11 at 06:48
  • 1
    If you let the load happen automatically, I don't think so, but if you just change a link setting and then add a few lines of code, then yes, it is possible. – Lou Franco Oct 13 '11 at 13:22
  • 2
    You don't actually need to do the calls through the GetProcAddress or anything like that. You are going to load just to check that the library is there -- then you call functions as you normally do knowing that the load process will succeed -- Delay Load just moves the LoadLibrary done by the runtime to when you actually use the DLL. – Lou Franco Oct 13 '11 at 13:23