19

Get the following error while linking my project in Delphi XE2. Recreating of .dproj file doesn't help.

[DCC Hint] H2161 Warning: Duplicate resource: Type 24 (user-defined), ID 1; File resource <filename>.res kept; file c:\program files\embarcadero\rad studio\9.0\lib\Win32\release\WindowsXP.res resource discarded.

How to fix it? Thanks for the help!

Dmitry
  • 14,306
  • 23
  • 105
  • 189
  • 1
    Just a note: I have noticed that from at least D2010 up (possibly D2009 up), the IDE cache sometimes gets in the way and you can get duplicate resource warnings on compiles. Do a build and they are gone. So nowadays whenever I see a duplicate resource warning, I first do a build and only start hunting if that doesn't clear it. – Marjan Venema Dec 22 '11 at 09:40

4 Answers4

23

You've got more than one application manifest linked to the application. There can be only one and so some have to be discarded. Modern Delphi versions link a manifest by default based on the "Runtime themes" project option. You possibly have another manifest linked, perhaps dating from when you developed the project in an earlier version of Delphi. Are you using the TXPManifest component by any chance?

You can remove the manifest that you are explicitly linking. Or you can disable the runtime themes setting and retain the explicit manifest. That latter way you are in control of the manifest. Personally that is the way I do it because I do need to have control over precisely what goes in the manifest.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thanks. But no one runtime theme is selected. I have tried to delete the one XPManifest on the main form - error still exists:( – Dmitry Dec 21 '11 at 22:32
  • There has to be another manifest somewhere! It's a question of hunting it down. – David Heffernan Dec 21 '11 at 22:35
  • Search by string 'TXPManifest' shows no results on all components and files of the project. – Dmitry Dec 21 '11 at 22:41
  • 2
    search for $R which links resources. Have you just upgraded delphi? – David Heffernan Dec 21 '11 at 22:44
  • 13
    Deleting the TXPManifest component isn't good enough. You have to remove the XPMan unit from your form's `uses` clause, too. (Adding the component adds the unit automatically, but removing the component doesn't remove the unit because the IDE cannot *know* that removing the unit is the correct thing to do. As we see in this case, the unit has side effects beyond just providing the component, and the IDE doesn't know whether you still want those side effects.) – Rob Kennedy Dec 21 '11 at 22:44
  • Thanks @rob. I've never used XPman myself but I guess the only way the resource can be linked is by including a unit with a $R. – David Heffernan Dec 21 '11 at 22:47
  • 3
    @DavidHeffernan: on a side note, XE2 introduces the ability to specify a custom manifest instead of using the default manifest. Go to `Project > Options > Application`, set `Runtime Themes` to `Use custom manifest`, and specify the filename of your .manifest file. You would still have to remove `XPMan` from the project, but this way you can now add additional criteria to the project manifest (UAC elevation, side-by-side assemblies, registration-free COM, etc). – Remy Lebeau Dec 22 '11 at 00:30
7

I had the same problem, and arrived on this page via Google.

Removing XPMan from the uses-clause fixed it.

Found the culprit via "find in files" with search term "xpman". Thanks for Rob Kennedy for suggesting this in the comment to David's answer.

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
  • Same here with the samples that came with Delphi Tokyo. They have XPMan in the uses list; if you uncheck 'Enable runtime themes', it will be re-checked for you ;-) – Jan Doggen Sep 19 '17 at 06:46
  • I was screwed after I removed XPManifest from Form1 and added xp_uac.res. This was XPMan in uses clause causing the issue. Thanks! – Shadab Mozaffar Aug 16 '19 at 14:46
5

Thanks for your help. For me, the following has helped:

{$ R * .RES} from project source removed
Arian
  • 51
  • 1
  • 4
  • Yes. Only removing helped me too. Removing XPMan from uses-clause nothing changes- it is created automatically.. – basti Feb 04 '21 at 22:12
-1

Removing {$R *.res} from project source helps. {$R *.res} is restricted in Delphi XE2?

Dmitry
  • 14,306
  • 23
  • 105
  • 189
  • That doesn't sound like the answer. You would be better using runtime themes option in project options if you want to influence the main app resource. Look for xpman unit as rob suggested. – David Heffernan Dec 21 '11 at 22:49
  • Removing {$R *.res} might have "as if solved" effect if you have included a manifest in your custom RC/RES file. It is better to remove the manifest from the custom RES file instead of deleting the whole RES reference. – Gad D Lord Feb 06 '15 at 00:51