Delphi: Unit X was compiled with a different version of Y

The dreaded message everybody gets every now and then.

The classic solution is:
– find all related pas and dcu files on your HDD and make sure there is only 1 copy of each.

However, sometimes this is not sufficient and that is because there is also a DCP and/or a BPL that was built with that unit somewhere on the IDE searchPath found before the one you are building. So you delete all pas/dcu, build the package and still get the error. This happens when you build a package which depends on the package in which the unit resides. And that is because when building packages, delphi will look at the DCP, not the DCUs (when the DCP is linked of course).
So basically the same problem as with the DCU.

In conclusion, the actual complete solution is to
– search and remove all affected DCUs
– make sure there is only 1 version of the PAS
– search and remove all affected BPLs and DCPs

Sometimes, you will need to close the IDE, and then when you start it again you may receive the other dreaded message: “Cannot load package”.

Now, it’s time to search for that package in the registry, specifically in the
– “Disabled Packages” key
– “Known Packages” key
– “Package Cache” key
Best is to remove it from everywhere. Then you re-install it once you manage to compile everything.

Related posts

Tags:

Leave a Reply

This blog is kept spam free by WP-SpamFree.