Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Duplicate Resource Error


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 7 - Last Post: Jan 24, 2018 8:14 AM Last Post By: Mark Williams
Mark Williams

Posts: 120
Registered: 5/8/10
Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 6:30 AM
I am using the UI framework in an application using the TurboPack component.

I keep getting a hint on compiling

[dcc32 Hint] H2161 Warning: Duplicate resource: Type 24 (user-defined), ID 1;

The message warns of a conflict between the res file for the app and the res file for UIRibbon and states that the uiribbon resource has been discarded. This causes problems later on when the ribbon framework tries to load the resource.

The contents of UIRibbon.rc is simply "1 24 "UIRibbon.manifest""

How do I avoid the conflict and retain the ribbon resource?
Mark Marks

Posts: 269
Registered: 9/11/00
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 6:44 AM   in response to: Mark Williams in response to: Mark Williams
Mark Williams wrote:

How do I avoid the conflict and retain the ribbon resource?

I had this between two third party components.
Renaming one of the resources was the only solution.
Renamed the resource in the resource file and searched the source and
renamed it. In my case it was a bitmap.

Another reason to always have the source.

HTH
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 8:58 AM   in response to: Mark Marks in response to: Mark Marks
I had this between two third party components.
Renaming one of the resources was the only solution.
Renamed the resource in the resource file and searched the source and
renamed it. In my case it was a bitmap.

Sadly not that simple. Done a bit of digging around in the resource. It creates a new manifest which I can only assume is designed to override the project manifest. However, the ribbon manifest does not incorporate all the other necessary resources such as VCLStyles, Icon, version info etc.

Ordinarily the discarding of the ribbon resource on compile is not an issue. However, I allow users to choose different vcl styles and save to the registry and then load the chosen style in the main forms oncreate. This is when it all falls down die to the resource issue.

Have tried renaming the project res and updating it with the necessary info from the ribbon res and loading the new res instead of the project res, but still doesn't work.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 9:58 AM   in response to: Mark Williams in response to: Mark Williams
Mark Williams wrote:

I keep getting a hint on compiling

[dcc32 Hint] H2161 Warning: Duplicate resource: Type 24
(user-defined), ID 1;

That means your project is trying to link with two separate manifests
using the same resource ID.

How do I avoid the conflict and retain the ribbon resource?

Which version of Delphi are you using? In modern versions, there is a
setting in the Project Options to disable the app's default manifest
resource.

--
Remy Lebeau (TeamB)
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 12:34 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
That means your project is trying to link with two separate manifests
using the same resource ID.

Which version of Delphi are you using? In modern versions, there is a
setting in the Project Options to disable the app's default manifest
resource.
Found it and disabled it. Thanks. That overcomes the initial warning. However, I am still getting a bug when I try to set the style in the formcreate event of the main form. It is failing on trying to load a particular resource connected with the ribbon. Turbopack comes with a compiler unit which creates a delphi unit (ribbonmarkup.pas). This gets added to the uses clause of the main unit of your form. It has an initialization section which (I think) loads the relevant resources for the ribbon.

If i do not set the form style in the form create method then all is well. If I do set it then the ribbon causes an issue in that it can no longer find the resources.

The initialization section of the ribbonmarkup unit is being called before the main form's formcreate. When formcreate tries to set the style for the form I believe it is doing something which may be causing the ribbon resources to be destroyed. Can't quite work out how that is happening, but can't think of any other explanation.

I have tried adding the setstyle routine to another unit's initialization section and making sure that unit is listed ahead of ribbonmarkup in the project file, but that doesn't work because the project resource file has not yet loaded so no styles are available. I have tried moving {$R *.res} above the uses clause, but that does not appear to effect the order of loading.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 3:57 PM   in response to: Mark Williams in response to: Mark Williams
Mark Williams wrote:

If i do not set the form style in the form create method then all is
well. If I do set it then the ribbon causes an issue in that it can
no longer find the resources.

That has nothing to do with manifests. Make sure the ribbon's
resources are being compiled into the final executable correctly.

The initialization section of the ribbonmarkup unit is being called
before the main form's formcreate. When formcreate tries to set the
style for the form I believe it is doing something which may be
causing the ribbon resources to be destroyed.

Resources are static in the eexecutable, they are never destroyed.

Can't quite work out how that is happening

That is what the debugger is for.

I have tried adding the setstyle routine to another unit's
initialization section and making sure that unit is listed ahead of
ribbonmarkup in the project file, but that doesn't work because the
project resource file has not yet loaded

Yes, it has. Resources are static, they are always available once the
executable file has been loaded into memory.

I have tried moving {$R *.res} above the uses clause, but that does
not appear to effect the order of loading.

No, it does not.

--
Remy Lebeau (TeamB)
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2018 9:42 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I have failed to get to the bottom of this. It makes no sense. The necessary resource actually exists at the appropriate time in either scenario, what is failing is a an API call to the ribbon framework, but I don't know why.

Have discovered the project is on Github and I have logged an issue there if anyone is interested.
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Duplicate Resource Error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 8:14 AM   in response to: Mark Williams in response to: Mark Williams
If anyone is interested in the solution it has been provided via Github. All that needs to be done is move the call to the trySetStyle function out of formcreate and to call it in the project file before the call to createForm.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02