there are many ways.
one: stuns. you can easily stun a yi or shaco or w/e and then kill them in 2-3 seconds.
two: rammus. Rammus is the anti-carry, and with thornmail and sunfires, can literally taunt them and they will die.
three: oracles/wards. once assassins lose the element of surprise, they become quite weak. Try blitz-pulling a shaco out of stealth. you will literally lol him to death.
typically the best way to counter a smart carry is to not let him get powerful in the first place. This means do not feed the carry, do not let the carry successfully set up ganks, do not give the carry level advantage. if this means exerting a significant amount of your resources in shutting down carries, it will be worth it late game. remember, carries excel late game but are pretty weak early game. capitalize on this. I'll give you a hint, casters are powerful early game but are weaker end game. try to use them to prevent the carry from getting a huge end game advantage by shutting them down early game using said casters. Annie, Veigar, Karthus are all good for this.