ModuleManager LoadModule hangs (on some machines)

Hello,

We have a C# Winforms host loading a Delphi (XE5) visual plugin. This works fine on most machines.

A little while ago (August) we had a problem where our software suddenly just stopped working on several client machines and we traced it to the line loading the Delphi module (ModuleManager.LoadModule(OurPluginName). When we tried to debug it from the Delphi side we found that it never got there, so it seems the problem was indeed literally loading the plugin. We tried to get to the bottom of it, but within a week or so, it began working again on all our client machines with no intervention from us. We put it down to a Windows Update fix or similar because there had been a “bad” Windows update released by Microsoft around the same time.

However, now, another user is having the same problem. They’re up to date with their Windows updates, so it’s not that. I tried disabling anti-virus etc., but it still didn’t work.

It sounds a bit similar to this item, but there doesn’t seem to have been any comeback on that one:
https://talk.remobjects.com/t/loadmodule-hangs-up-w-delphi-plugin-in-a-winforms-c-host/4034

I’m at a bit of a loss - can you think of any reason why “LoadModule” would fail in this case?

Regards,

Rob H

Hello

Unfortunately no. I’ll have to ask you to try to do the same thing that is mentioned in the original post - to try to pinpoint in the debugger where exactly the process hangs. I cannot reproduce it locally, so I cannot fix it w/o more information from you.

Hello,

As I mentioned in my original post, I have debugged it - the LoadModule is the last line (on the C# side that executes) and it never gets to the Delphi side, so that is all the information I can give you.

Can you tell me what LoadModule (in detail - obviously I know it load the plugin :slight_smile: ) does so I can try and get to the bottom of the problem?

Thanks,

Rob

Load .pdb files for the Hydra assemblies (or use dotPeek to work as Symbol Server - incredibly handy to debug literally anything in .NET). So you’ll be able to get closer to the real code line causing issues.

I’m revisiting this as now the problem has got more serious. After upgrading to Delphi 10.1 Berlin and the latest version of RemObjects Hydra, this behaviour now happens on ALL machines. I traced the line of code to this:

constructor LoadedUnmanagedModule(aFilename: string); 
begin
  fDllHandle := UnsafeNativeMethods.LoadLibrary(aFilename);  <-- This causes the application to hang 

What could cause it to never return?

Regards,

Rob H

Hello

This is a direct call to the WinAPI method LoadLibrary https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx

This method is expected to hang is anything non-trivial is going in the Dll Main, esp. any API calls
Please double-check that your initialization code doesn’t contain any suspicious calls. If that doesn’t help then please send us a testcase to support@. I would need a host app (try to use the host app from the samples to see if the issue reproduces there), sources of the plagin and this plugin in compiled form (w/o packages so that it could be used on a host w/o Delphi or Hydra installed)

Thanks in advance

PS Could you also check if the loading of the same plugin into Delphi sample host hangs too?