Share via


Passing XmlDocument object as argument while using .NET Remoting

Just got a problem where developer was passing the object of XmlDocument in a remoted object's method. And he was getting error,

Errror : {"Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."}

And above behavior is expected because XmlDocument is already containing XML data which can not be serialized once again. The workaround to the problem is, we should use "string" as argument to pass the InnerXML between the remoting client and host, and generate the XmlDocument once again on the server side. That can solve the issue.