Monday, February 21, 2011

Delphi 7 compile error - “Duplicate resource(s)” between .res and .dfm

I got a very similar error to the one below:

http://stackoverflow.com/questions/97800/how-can-i-fix-this-delphi-7-compile-error-duplicate-resources

However, the error I got is this:

  [Error] WARNING. Duplicate resource(s):
  [Error]   Type 10 (RCDATA), ID TFMMAINTQUOTE:
  [Error]     File P:\[PATH SNIPPED]\Manufacturing.RES resource kept; file FMaintQuote.DFM resource discarded.

Manufacturing.res is the default resource file (application is called Manufacturing.exe), and FMainQuote is one of the forms. .dfm files are plain text files, so I'm not sure what resources is being duplicated, how to find it and fix it?

If I tried to compile the project again, it works OK, but the exe's icon is different to the one I've set in Project Options using the "Load Icon" button. The icon on the app is some sort of bell image that I don't recognize.

From stackoverflow
  • Try renaming Manufacturing,res to Manufacturing.bak or something. Delphi should recreate the res file.

    You would of course need to recreate any references, strings etc in the res file in the new one, but worth trying anyway...

    Robo : Thought I tried that already, but I think I needed to restart Delphi or something to get it re-create correctly. The other problem I encountered which confused things a bit was Delphi 7 didn't like the 32 bit icon I used. Ran without errors when I used a simpler (but crappier looking) icon.
  • try looking for having an extra {$R *.res} or {$R *.dfm},you may have copied it from somewhere.

  • Delphi converts all of your DFM files into resources, and names them the name of the class. You can verify this by using a resource editor and opening any of your form based Delphi applications.

    search all of your units for instances of the TFMMAINTQUOTE form. Its most likely in two units, one of which is NOT linked to your project, but is being pulled in via the uses clause referencing the wrong unit (wrong as in it is saved with a different name but has the SAME form name, if it was part of your project then the compiler would complain when you added the unit in the first place).

    The simple solution to this problem is to find the TFMMAINTQUOTE form IN your project and rename the form to something else, but then the old TFMMAINTQUOTE will still be pulled in.

    I suggest using a good directory grep tool such as the one in GExperts to do your searching. It will save you alot of time and can be set to search your entire hard drive if so desired. The advantage of GExperts is that its free and integrates directly into the Delphi IDE.

    Erick Sasse : I can't live without GExperts Grep Search. ;)
    Robo : Thanks, I'll give GExperts a go, the ability to search/replace for the whole project directory is something I need.
  • I just had the same problem and found an extra {$R *.res} in there.

  • the extra {$R *.res} is in the *.dpr file like this:

    program Test;

    uses Forms, Unit1 in 'Unit1.pas' {Form1}, Sample in 'Sample.pas', Proc in 'Proc.pas';

    {$R *.res} //<----delete this if you put them in the Unt1.pas. ok.

    begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.

  • If you rename a from and this form is referenced in the Uses part of other Units then you get the above error.

    Solution is a mixture of the above.

    (1) Change the resources file ending to .bak (so it will be re-created later). (2) Search through all the units and change the reference to old unit/form name to the new one. (3) re-compile and will now be ok.

  • I got the same error. I think that the contributing factors were: 1) no *.res-file 2) common units with another project 3) the project with the error had a form with the same name as a form in that another project

    Solution: rename the form (in the project with the error message)

  • Edit the RES file and delete from it the duplicate resource. This way you will be able to keep your original icon.

0 comments:

Post a Comment