LoadModule() hangs up w/ Delphi plugin in a Winforms C# host

I have a fairly large Delphi app in XE5 that we are trying to embed into a Winforms C# .NET 3.5 app (VS2010). During the call in the Winforms host to “moduleManager.LoadModule(DELPHI_PLUGIN_PATH);”, the program locks up and just spins forever. No exception thrown, and I must terminate the program in Visual Studio.

I am looking for insights into what is happening here, and/or ways to debug this. Any ideas would be greatly appreciated.

More info…

  1. While trying to debug this, I created a Delphi host app based on the “Simple Visual” example code to see if the plugin ran okay with a Delphi host. The plugin works fine with the Dephi host, and I am able to view and run the Delphi plugin with no issues.
  2. I moved the Delphi host exe to the same folder as the Winforms app exe, and tried it again. The Delphi host app worked fine there too. Note that this is where the Delphi plugin dll resides also for use in the Winforms app, so the Delphi host app is using the same plugin dll as the Winforms app. Delphi host runs fine.
  3. After much digging, I found that our original Winforms app did not have “[assembly: ComVisible(true)]” set correctly in the AssemblyInfo.cs file. I then started from scratch by creating a new Hydra Winforms Host project in Visual Studio just like in the example found here: http://wiki.remobjects.com/wiki/WinForms_Host
    Unfortunately, this did not help either, and I get the same result with the Winforms host app locking up with the call to “moduleManager.LoadModule();
  4. I then went back to Delphi and created a BPL package that encapsulates my original app. I created another Delphi test app with a single main form that uses the BPL package to load the TFrame control that encompasses my original app. This test app also runs fine.
  5. I then created a new Delphi Hydra plugin module that uses the BPL package instead, and created another Delphi host app to test the plugin and BPL combination. It also worked fine, but the Winforms host app still hangs when loading the Delphi plugin.

Any help would be VERY much appreciated. I’ve been struggling with this for almost a week now. Thank you.

You can try to attach debugger to your application and pause it to take a look where does it hangs, on both Delphi and .NET sides, maybe this will show what can cause this problem.

Thank you ejay. Can you recommend a debugger that would work well in this situation? Is there one that you use over another?

We are using regular Delphi and Visual Studio debuggers.