One of the things that gets CRM 4.0 developers into trouble is moving customizations between organizations. Here is a tip that will prevent a lot of grief trying to troubleshoot some of the more confusing errors:
Always, Always, Always export all of your customizations from the source environment.
You can always import only the items that you are working on. The Import Customizations page allows you to select the items being imported.
Using this technique gives CRM all of the information about your customizations and schema so it it needs some secret little part of something, it is available.
Sometimes it will miss data or other relevant information and while not producing an error, may not fully recreate the customizations as you defined them within the source environment.
I have seen this appear as lost icons, invalid relationship connections, and just plain strange stuff that takes hours to find and fix.
Last year, I ran into such a situation where we could not Publish All Customizations.
It took me about 6 hours to find and fix but the problem was related to a custom entity that was, well, broken. I had to manually insert a record into the database to fix it. ( and yes, that scared the crap out of me. )
It is my firm belief that this occurred because the person who installed the customizations only moved the four entities required from one organization to the other.
My initial solution was to export all customizations from the original source organization, import only those four entities into the development environment, then finish the remainder of the database cleanup manually.
This process had to be duplicated to the test and production organizations as well.
All in all, not a fun time and one that stretched my personal and professional expertise to the limit.