Serialization Constructor
For your class to be serialized by Xml Serializer it is needed that it has a default constructor... For your class, if you only have a constructor which takes some fixed arguments and does not have a constructor which takes in no arguments the serializer is not able to create an instance of your class to serialize and so it fails with an error..
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: ApplicationName.ClassName cannot be serialized because it does not have a default public constructor.
Similarly error might also occur in case you are using Activator class's Create instance method for some type which does not have default public constructor and you are not passing the constructor parameters...
So in short if it is not harming the base functionality it is always good to have default constructor for your class...
PS: Most of the manufacturing industries have got their "Labor Unions" in place... These bodies have helped putting a check on unscrupulous and inhumane employers from illtreating their employees... Manufacturing industries have been here since ages, but IT industries have just came into being... How about starting "ILU (Information technology Labor Union)" which will be a social regulatory body that will be a registered organization with WTO and funded by all the "good IT employers"... Being registered in the organization will help employers to go up the ladder in the "Best Companies To Work For" list/awards; also not getting any complains registered against the company in ILU would help... Moreover this body will be a neutral regulatory body and thus any employee working in any IT firm can register a complain and this body will make sure that no injustice will happen to the employee... This body can help employees raise rightful voices which would be given just 'lip services' or even worst deaf ear otherwise... I am planning to write a white paper on this idea; but then I am not sure whom to forward it to... If you have any tips let me know...
BTW, just FYI my employer is treating me really very well, but then I wish everyone feels the same about their employers too... Well this is a big IP I am sharing out on the blog... So the copy rights notice goes along with... If you want to start something of this sort contact me and we will get it rolling... :-)
No comments:
Post a Comment