| David Dindorp 2005-02-21, 8:57 am |
| I'm doing a piece of code which serializes exceptions in a
HttpApplication and stores them in a database.
Can anyone provide a good, preferably technical, explanation to why
sub-classes does not inherit attributes implemented by their super-classes?
Example (compile with a reference to System.Web.Dll):
=====
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web;
class SerializeExceptionTest {
static void Main(string[] args) {
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
Exception a = new Exception();
Exception b = new HttpException();
formatter.Serialize(stream, a);
/**************
* This next line fails with an error stating that the object is not
serializable.
* 'b' is declared as an Exception, and the Exception class is marked
Serializable.
**************/
formatter.Serialize(stream, b);
}
}
|