Error programming avrdude: stk500_recv() not in sync when attached to shield

When we try to program Arduino UNO rev.3 with our custom made shield attached, it gives this error, it programs correctly if the shield is not attached or another shield is attached.
What could be the problem?
Due to some ports busy occupied by our shield.
I specify that the shield has also an external power supply (12V) that is not attqached when we program Arduino because when we use Arduino, this power supply will supply power to the shield and also to Arduino with Vcc in pin.
We have also tried to put a diode for decoupling this power supply.
What can we do?

The problem could be your shield is doing something with pins 0&1, those are the lines required to program.
The other thing is that your shield could be shorting something out, this is not uncommon.

so if pin 0 & pin 1 are busy is not possible to program.

so if pin 0 & pin 1 are busy is not possible to program.

That is correct.
If something else is holding these pins and stopping the serial data getting through it is not going to work.

We have checked and there is nothing in the program or in the circuit holding these pins.
Moreover it seems all woking in the shield, without noticeable wiring shorts.
In which way do you suggest to proceed in order to discover the possible issue?

You need to look with an oscilloscope to se the signals from the computer are appearing on pins 0 & 1 with the shield on.

I know you have checked visually but only the shield either interfering with the power supply or those pins would stop it from working. Measure the 5V with and without the shield attached.

Thanks to all. Solved
There were a short under a pin strip in our shield, where connected to Arduino