What the mentioned MSDN example misses is the KeyInfo
structure in the created signature. KeyInfo
lets you even include the certificate in the signed document which makes it totally portable - the certificate is a part of the signed document which means that at the receiver side you not only can validate the signature but also accept or reject the certificate (usually this involves thumbprint lookup).
What I also disliked in the MSDN article is the lack of theory - there are three types of signatures - enveloped, enveloping and detached. The distinction could be important and it is better to have a deeper understanding of what is going on.
This is why I wrote a three part tutorial that covers the interoperable XMLDsig. I show how to create and validate signatures in C# and Java in an interoperable way:
Part 1 (theory) http://www.wiktorzychla.com/2012/12/interoperable-xml-digital-signatures-c.html
Part 2 (C#) http://www.wiktorzychla.com/2012/12/interoperable-xml-digital-signatures-c_20.html
Part 3 (Java) http://www.wiktorzychla.com/2012/12/interoperable-xml-digital-signatures-c_4247.html