Hi Ashutosh,
As for the "SerializableAttribute", it is the same as other .NET Attributes
which decorate the certain class or class member (SerializableAttribute is
for class level). And the compiler will just emit some info in metadata of
the certain class to indicate that the class has marked with serializable.
About "how this attribute will work at runtime", here is the case when it
will perform important roles:
**Whenever you try persist a class instance into some storage which need to
ensure the class is serializable(the serialize here is binary serialize),
such as SQL Server session state, ASP.NET ViewState, , the runtime will try
inspecting the metadata of that class to see whether it has been marked
with this attribute. If so, that instance will be serialized(by the .NET
runtime's default object serializer) and stored into the target storage.
Otherwise, exception will be thrown.
**Or if you explicitly use BinarySerializer to serialize a class instance,
the runtime will also perform such check to ensure the class is
serialize(either marked with this attribute or has explicitly implement
the ISerializable interface).
Also, from the "how the binary serialization is implemented" perspective,
using "SerializableAttribute" means you let the .NET runtime help you
generate the object serializing rule and logic automatically. While if you
manually implement "ISerializable" interface, you will need to add the code
logic for serializing the certain class's instances.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------