21.Explain the Limitation and advantage of XmlSerializer?
Limitation:-
XmlSerializer has severe limitations such as
the requirement that the target class has a parameterless constructor,
and only public read/write properties and fields can be serialized.
Advantage:-
However, on the plus side, XmlSerializer has good support for customizing the XML document that is produced or consumed. XmlSerializer's features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents.
22. Explain the Limitation and advantage of SoapFormatter/BinaryFormatter?
SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on Deserialization the constructor of the new object is not invoked.
The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and Deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else.
23. Can the serialization process can be customized?
Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class.
For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field.
Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer's [XmlIgnore] attribute.
But the Ultimate control of the serialization process can be achieved by implementing the ISerializable interface on the class whose instances are to be serialized.
24. Why is XmlSerializer so slow?
There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean,
for example
That XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.
25. Can I serialize a Hash table with XmlSerializer?
Any class that implements Idictionary will by be refused XmlSerializer.
e.g. Hashtable.
Soap Formatter and BinaryFormatter do not have this restriction.
26. What is CAS?
CAS-Code Access Security
CAS is the part of the .NET security model that determines
- whether a piece of code is allowed to runor not and
- what resources it can use when it is running.
27. How does CAS work?
The CAS security policy revolves around two key concepts –
Code groups and permissions.
Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set.
28. Who defines the CAS code groups?
Default groups are defined by microsoft,but you are allowed to modify and even create your own. To see the code groups defined on your system, run 'caspol -lg' from the command-line. On my system it looks like this:
Level = Machine
29. Can I look at the IL for an assembly?
Yes. A microsoft tool called Ildasm which can be used to view the metadata and IL for an assembly.
30. Whether source code be reverse-engineered from IL?
Yes, it is often relatively straightforward to regenerate high-level source (e.g. C#) from IL.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment