MSDN documentation states that :
StreamingContextStates.CrossAppDomain specifies that the source or destination context is a different app-domain.
I know what app-domains are but still it doesn’t help me understand the actual idea of StreamingContextStates.
Can some one explain it to me in an easy (less technical) language.
I’m not that good at understanding a concept just by reading it’s documentation.
The idea here is that if you want, you can save resources by using different serialization in different scenarios. For example, it might be that some of your data is in some OS resource that will work for your entire process.
If you have multiple
AppDomains in a single process, and are using remoting to talk between them, then when you spot theCrossAppDomainoption you might just copy the underlying OS handle – that existing handle is just as valid from eitherAppDomain, since the OS handles don’t really know about app-domains.IIRC,
stringis actually valid over an entire process space, without need to serialize – so that might be an interesting case to just keep the reference.Other options would be same-app-domain, same-machine, different-machines, etc.
IMO though, this just exposes you to additional complexity. It would only be worth worrying about in very specialized scenarios. In the general case it is better just to serialize to a pre-defined storage representation, and rehydrate.