0

One week ago I had to fix a DLL that I use on my software that allow me to do some mail merging on Excel. The error that I got was that the midas.dll was not found.

The problem is that if I add the uses Midaslib on the DLL, call one of the function of the DLL and then destroy the handle of the DLL, It will result on some acces violation on the main software because it use ClientDataSet.

My theory is that the Midaslib call, who are necessary for the usage of ClientDataset, has been flush out of memory or somethings that I can't understand now.

Do any of you had the same problem ? If so do you have any solution please ?

If the information can be usefull, I'm on Delphi 10.4.

  • 1
    Welcome to StackOverflow! Is the error you got (midas.dll not found) the reason of fixing the DLL? Or the DLL started to malfunction because you fixed something else and added Midas? When you says "destroy the handle of the DLL", do you mean you call FreeLibrary with the handle of the DLL? – fpiette Feb 25 '21 at 09:57
  • `Midas.dll` will register its `path` in the registry and any calls to it will use that registry path to find it. So most likely your `midas.dll` has been moved to another location and now all Delphi software cannot find it anymore. Either put the dll back to its original path or re-register midas into the registry so the path is up-to-date again – GuidoG Feb 25 '21 at 10:25
  • 1
    Does this answer your question? [Midas.dll error loading midas.dll](https://stackoverflow.com/questions/25877533/midas-dll-error-loading-midas-dll) – GuidoG Feb 25 '21 at 10:27
  • Hello ! Thanks you for your answer. Yes the error is the reason why I try to add the uses and yes and I say destroy, I mean FreeLibrary, sorry for the misunderstanding fpiette. – Julien ARMAND Feb 25 '21 at 10:35
  • Hello GuidoG, thanks for the suggestion. I will try what the answer on this post suggest and will come back with some news – Julien ARMAND Feb 25 '21 at 10:39
  • I never ever use the midas.dll anymore, because of the fact different versions cannot work nicely together. Especially when someone registers a midas.dll, because then that might get loaded even when you have the correct version inside your application folder. I know adding MidasLib to the project will make it bigger, but it’s a very small price to pay for not having al kind of midas.dll version trouble!!! – R. Hoek Feb 25 '21 at 17:03
  • I already got the midaslib uses on the main application because it use some clientdataset who need it. My problem here is that one week ago my dll mysteriously start to say that it need the midas.dll to work now. So I add the midaslib to the dll but the problem is that the midas dll has only one memory instance and when I call the FreeLibrary of my own dll, the midas dll is flush out too and then the main application can't work anymore because of the ClientdataSet – Julien ARMAND Feb 26 '21 at 10:12
  • 1
    @JulienARMAND why are you loading midas.dll in your main app? When you use midaslib you don’t need to do that al all (and you don’t have to distribute the midas.dll too). – R. Hoek Feb 26 '21 at 13:45
  • I don't understand why calling FreeLibrary on your own dll would also flush out midas.dll also. Are you loading midas.dll yourself in some way ? – GuidoG Feb 26 '21 at 14:49
  • If you have MidasLib in your main app, it does not use Midas.dll at all, so the issue is not related to that at all. The issue is somewhere in your DLL code. The main app never touches or uses or loads Midas.dll if MidasLib is in the uses - the entire purpose of the MidasLib unit is NOT to have to use Midas.dll. – Ken White Feb 27 '21 at 01:54

0 Answers0