1
Answer

Clone the Generic type

Rajesh Kumar

Rajesh Kumar

11y
1.1k
1
Hi,


           i am facing   Cannot serialize a generic type 'Microsoft.Practices.Prism.Commands.DelegateCommand`1[System.Object]'.
           when Cloning.i am using the below method for cloning.

 public static T TrycloneElement<T>(T orig)
            {
                try
                {
                    string s = XamlWriter.Save(orig);

                    StringReader stringReader = new StringReader(s);

                    XmlReader xmlReader = XmlTextReader.Create(stringReader, new XmlReaderSettings());
                    XmlReaderSettings sx = new XmlReaderSettings();

                    object x = XamlReader.Load(xmlReader);
                    return (T)x;


                   
                }
                catch
                {
                    return (T)((object)null);
                }

            }

please give me the solution

Thanks
Rajesh.
Answers (1)