Build Delphi action creating corrupt EXE when compiling 64 Bit with Delphi XE4 and Regenerate Resource

Error reproduced on two platforms with different versions.

  • FB 7.0.0.2528, windows 7, SP 1 (64 bit version)
  • FB 7.0.0.2641, windows Server 2008R2, SP1 (64 bit version)

I am not sure how to get you something to reproduce this, but maybe someone else will come up with a simpler case or I will later.  At least anyone else encountering this will know what circumstances sets up this problem.

We have a couple of applications (not all) and it is our biggest two applications (is not that always the case), that exhibit the following behavior:

Compile configuration:  We compile 64 bit with Regenerate Resource to provide the Version Information in the program properties.  We are not using property sets. Instead, we have variables specified in the Version Information tab of the Build Delphi action.  The error we get when running the application is "The application was unable to start correction (0xc000007b).

We do not get this error if we compile in the IDE with version information (but of course we use FB to automate builds every night).  We do not get this error if we turn off regenerate resource (prevents updating our version information) in the Build Delphi action of FB. We still get this error if we do a 32 bit compile with Regenerate Resource before building the 64 bit version with Regenerate Resource turned off on the 64 bit build.  Once we do a build with Regenerate Resource, 64 bit builds will be bad until we restore the source folder (or open Version Information in the IDE itself which corrects the issue).

The 32 bit version of our application runs fine when we build it with Regenerate Resource, but it sets up the 64 bit compile to fail.

It appears that the manner in which FB regenerates the resource file is different than the IDE.

My work around solution will be to put static Version Information into the 64 bit version of the application at design-time and display version information that is compiled into the application during a build in the caption heading of the app.  Right click properties on the EXE file will show something like 14.2.0.0 instead of 14.2.1.13 (which will display on form caption).  I'll make sure the 64 bit app compiles first (or restores the resource file).

Actual error is “The application was unable to start correctly”

Hi Guy

Could this be the problem?

http://stackoverflow.com/questions/11174743/delphi-manifest-for-uac-elevation-in-64-bit

Try specifying a custom manifest file. Also, if you are using the old XP Styles component then remove it from your project (and remove the uses clause for it).

I solved the issue by reverting the dproj file back to an old copy.  Something in the dproj file was messed up and caused it to create a bad resource file.

Hi,

I’m having exactly the same problem with Regenerate Resources under 64 bit. If I uncheck the option the exe runs as expected. If I check it I get the “application was unable to start” error.

I’ve tried regenerating the dproj file, but I still get the error. If I diff the good and bad exes I see several areas where they differ.

Anybody got any other ideas?

Cheers,
Paul

Hi Paul

What version of Delphi? What settings do you have on the resource compiler tab for the manifest file. Regenerate Resources does the following :

Generate a .rc file with the version information, main icon, and (if specified on the resource compiler tab), manifest file and custom styles.

Invoke the resource compiler to generate projectname.res

If the manifest file is incorrect (ie for 32 bit) then you will get this sort of error because the manifest is telling windows to supply common dll’s that are for 32bit only. The fact that it runs when not regenerating the resource suggests a difference in the manifest.

Try this. Build the project in the delphi IDE. Then load up your finalbuilder project, and on the delphi action, click the “Form project File…” button next to the delphi project name, and select “Regenerate Manifest File”. That will extract the manifest file out of the .res file generated by the delphi IDE and tell the action to use that file. Makes sure you add the manifest file to version control.