If you marshal WPF windows between processes, or do any other cross-process remoting, you can get this error on an unpatched .NET Framework 4:
Invalid type code in stream 'Invalid'
This is not your fault: it is Microsof’ts bug.
The fix is here: http://support.microsoft.com/kb/982638