Modern software systems have become increasingly complex and they are used to perform vital functions in todays society. It is therefore crucial that software systems are as free of errors as possible. A software system is usually divided up into communicating components and there are restrictions on how the components can communicate. This thesis presents an approach for reducing errors in software system by validating, at runtime, that the restrictions are not violated. In this thesis the restrictions on the communication are specified as expressions over the communication histories of the components and the restrictions are represented either as an automaton or a state machine.