Skip to content

14. XMLSerializer, Catch(Exception), Debug.Write/Trace.Write

February 25, 2011

40. How does the XMLSerializer work? What ACL permissions does a process using it require?
XMLSerializer Class serializes and deserializes objects into and from XML documents. The XMLSerializer enables control of how objects are encoded into XML. XML serialization is the process of converting an object’s public properties and fields to a serial format(in this case XML) for storage or transport. Deserialization re-creates the object in its original state from the XML output. Serialization can be thought of as the mechanism of saving the state of an object into a stream or buffer. For example, ASP.NET uses the XMLSerializer class to encode XML Web Service messages. The data in the objects is decribed using programming language constructs like classes, fields, properties, primitive types, arrays, and even embedded XML in the form of XMLElement or XMLAttribute. To transfer data between objects and XML requires a mapping from the programming language constructs to XML Schema and from the XML Schema to programming language constructs. The XMLSerializer and related tools like Xsd.exe provide the bridge between these two technologies at both design time and run time.
ACL is access control list with respect to the file system, is a list of permissions attached to an object. ACL specifies which users or processes are granted access to objects as well as which operations are allowed on the object. Since XMLSerializer for performance reason caches the temporary assemblies, so the XMLSerializer requires full permission to read, write and delete on the temporary directory.

41. Why is catch(Exception) almost always a bad idea?
catch(Exception) does not enable proper exception handling. An analogy is throwing all vegetables in a bucket hoping that a good soup will result. Handle the more specific exceptions first and generalized last. Catching all exceptions with one generic exception handler is called bug masking and does not permit uncovering the bug that caused the exception and then go and fix it.

42. What is the difference between Debug.Write and Trace.Write? When should each be used?
Debug.Write writes information about the debug to the trace listeners in the Listeners Collection and only in Debug mode builds.
Trace.Write writes information about the trace to the trace listeners in the Listeners Collection for both debug and release mode builds. Debug.Write is used while debugging a project and Trace.Write is used in the released version of the Application.

Happy Programing! =)

Source: mainly MSDN,,

From → OOP

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: