Code-switching and code-mixing are synonyms. They mean the same thing. Speakers code-switch when they mix structures, meaning, and/or words of one language with another language. For example, Chinglish (a variation of Chinese and English) is an example of code-switching; Japlish (English and Japanese) is also an example of code-switching. When on vacation, we all code-switch. We utter sentences using a mixture of words, meanings, and structures form our native language and the language spoken in the country we're visiting. For example, while in Japan a tourist can be heard to say,
"Bank doko desu ka?" (meaning, Where is the bank?)
In Japanese, the same sentence is "Ginko doko desu ka?". 'Ginko' means bank. The tourist switched codes (i.e. words). Codes can be words, meanings, or even structures, like,
"Bank go." (meaning, I will go to the bank)
The structure mimics Japanese sentence structure (object+verb) but houses English words. That's code-switching.
When learning a second language, speakers draw on the knowledge of their first language. Borrowing words, meanings, and structures from one language to express yourself in another language is called code-switching. The term code-mixing means the same thing, but, linguists use the term 'switching'.
As for dissonance, well, as tdol mentioned it has to do with cognitive theory, specifically the choices one makes in deciding what to do about a behavior. The assumption is this. The lower the incentive, the greater the probability a person will want to change her/his behavior. In contrast to dissonance, there are behaviorist theories, which hold the opposite view: the higher the incentive, the greater the probability a person will want to change.
In other words, how do we get ourselves and/or our students to stop code-switching (i.e. marrying two languages)? Should greater emphasis be placed on not doing it or should less emphasis be placed on not doing it or can the solution be found in a mixture of the two? Dissonance deals with those questions.