For Programmers: Free Programming Magazines  


Home > Archive > C# > February 2005 > catching / serializing HTTP errors









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author catching / serializing HTTP errors
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);
}
}
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com