Jump to content
Achim Kalwa

Runtime Error 217 when installing GExperts

Recommended Posts

Posted (edited)

I did a clean install of Delphi 10.4.2. One of the first steps is to compile and install GExperts. SVN revision 3449 compiled fine, but when running the "Register-GExperts-XX104.cmd" it fails with "Runtime error 217 at 50CDB390", followed by "Problem beim Starten von .\GExpertsRS104.dll. Eine DLL-Initialisierungsroutine ist fehlgeschlagen."

 

To trace the error I compiled GExperts in Debug mode, using Debug-DCUs. Then I used Run->Parameters to set "C:\Windows\System32\rundll32.exe" as "Host", and the full path to the compiled GExpertsRS104.dll and ",InstallGExperts" as parameter:

 

Host application:
C:\Windows\System32\rundll32.exe

 

Parameters:
C:\Full\Path\To\GExpertsRS104.dll,InstallGExperts

 

Now I could debug the installation from within the Delphi IDE.

The startup-code InitUnits (in System.pas) initializes all units and calls class constructors; and in Vcl.WinXCtrls.pas it calls a class constructor TSearchBox.Create. This code creates an internal TImageCollection and adds two default images, which finally leads to TWICImage.Create in Vcl.Graphics.pas (Line 10624 ff).

 

The call to CoCreateInstance(CLSID_WICImagingFactory, ...) fails with error code $800401F0 = CO_E_NOTINITIALIZED =  'CoInitialize has not been called' and an exception is raised with message 'Cannot create instance of class CLSID_WICImagingFactory'.

 

To solve this problem, I need to insert CoInitialize(nil) somewhere, and because I won't change VCL and RTL units I had to find another place. Finally I found that the initialization block in GX_GenericUtils.pas is called some steps before the exception is raised, and already uses unit ActiveX, so I placed a CoInitialize(nil) in GX_GenericUtils.pas initialization block.

initialization
  CoInitialize(nil);  // this line added
  Initialize;
...

And the error is gone!

Finally I could install GExperts into Delphi 10.4.2 😉 [Yes, I know how to use RegEdit].

@dummzeuch : Maybe there is a better place to insert that missing CoInitialize(nil). Also I don't know if that call has side effects on older Delphi versions and should be surrounded by some IFDEFs. Since it is only one line inserted, I did not create a patch.

 

I'm going to report this new VCL bug to quality portal.

 

Thanks for reading,

Achim

Edited by Achim Kalwa
QC -> Quality Portal
  • Like 1
  • Thanks 2

Share this post


Link to post

How nice. The issue RSP-33120 has been closed as "test case error" and the comment says:

Quote

The call to to call CoInitialize(nil) in such a case is up to the developer, as we cannot figure out all possible usage scenario, including COM invocation and threading models.

 

Share this post


Link to post

Another option would have been to use the stand alone ExpertManager. That's what I did and it worked.

 

I just used it to uninstall GExperts and tried your way. I got the same error, but only after the command line window seemed to hang and I closed it.

Share this post


Link to post

Hi Thomas,

Errors when building #3451 D2007 & D10.4.1.

 

Regards,

Ian

Screenshot_1.jpg

Share this post


Link to post

Hi,

 

you must add to  <DCC_UnitSearchPath>. 

the following pathm  ;..\..\source\Utils;$

 

then you can compile it again

 

Torsten

Share this post


Link to post
9 hours ago, Ian Branch said:

Errors when building #3451 D2007 & D10.4.1.

Screenshot_1.jpg

Ooops, yes, I forgot to add the new unit to the other projects.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×