![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | XML Serialization OK, I have an object that I would like to serialize to an XML file. I can do that successfully, but if I modify the object to have a constructor that takes parameters, I get the following error message: Object cannot be serialized because it does not have a parameterless constructor While this error message makes perfectly clear what the problem is, I still don't understand why this is a problem. My google skills seem to be lacking today too. Can anybody out there explain why I can't serialize an object to XML if it has a constructor that has parameters? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: XML Serialization I believe it is as simple as "How would the system know which elements to feed to the constructor?". By the way, having both an parameterless constructor as well as the one you want with parameters is permitted. "Tom" wrote: Quote: > OK, > > I have an object that I would like to serialize to an XML file. I can do > that successfully, but if I modify the object to have a constructor that > takes parameters, I get the following error message: > > Object cannot be serialized because it does not have a parameterless > constructor > > While this error message makes perfectly clear what the problem is, I still > don't understand why this is a problem. My google skills seem to be lacking > today too. > > Can anybody out there explain why I can't serialize an object to XML if it > has a constructor that has parameters? > > Thanks. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: XML Serialization > Can anybody out there explain why I can't serialize an object to XML if Quote: > it has a constructor that has parameters? the serialized object will need values for the parameters and pass them to it in order to create an instance. See the problem? Best Regards -- Michael Justin SCJP, SCJA betasoft - Software for Delphiâ„¢ and for the Javaâ„¢ platform http://www.mikejustin.com - http://www.betabeans.de |
My System Specs![]() |
| | #4 (permalink) |
| | Re: XML Serialization > Can anybody out there explain why I can't serialize an object to XML if Quote: > it has a constructor that has parameters? the serialized object will need values for the parameters and pass them to it in order to create an instance. See the problem? Best Regards -- Michael Justin SCJP, SCJA betasoft - Software for Delphiâ„¢ and for the Javaâ„¢ platform http://www.mikejustin.com - http://www.betabeans.de |
My System Specs![]() |
| | #5 (permalink) |
| | Re: XML Serialization > Can anybody out there explain why I can't serialize an object to XML if Quote: > it has a constructor that has parameters? the serialized object will need values for the parameters and pass them to it in order to create an instance. See the problem? Best Regards -- Michael Justin SCJP, SCJA betasoft - Software for Delphiâ„¢ and for the Javaâ„¢ platform http://www.mikejustin.com - http://www.betabeans.de |
My System Specs![]() |
| | #6 (permalink) |
| | Re: XML Serialization Ah yes ... Thanks guys. "Family Tree Mike" <FamilyTreeMike@xxxxxx> wrote in message news:8039A762-8494-41AF-9E06-711973EF0703@xxxxxx Quote: >I believe it is as simple as "How would the system know which elements to > feed to the constructor?". > > By the way, having both an parameterless constructor as well as the one > you > want with parameters is permitted. > > "Tom" wrote: > Quote: >> OK, >> >> I have an object that I would like to serialize to an XML file. I can do >> that successfully, but if I modify the object to have a constructor that >> takes parameters, I get the following error message: >> >> Object cannot be serialized because it does not have a parameterless >> constructor >> >> While this error message makes perfectly clear what the problem is, I >> still >> don't understand why this is a problem. My google skills seem to be >> lacking >> today too. >> >> Can anybody out there explain why I can't serialize an object to XML if >> it >> has a constructor that has parameters? >> >> Thanks. >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Serialization optimization | .NET General | |||