Is there a way to force derived classes to implement serializable?

I have a base class which is serializable. When I distribute this class I need to ensure that any derived classes will have to implement serializable or throw an error. After looking through the documentation I added the [Serializable] attribute, will this do it?
[264 byte] By [Lorren] at [2008-2-13]
# 1
Well is there a way NOT TO force your derive class to implement the Interface?
;)
I mean it is naturally in OO paradigm the derived class to implement the bare minimum of its base class functionality.
So I do not think you should take any extra considerations.
BTW why dont you try it for yourself.?
PetarPetrov at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Remoting and Runtime Serialization...
# 2
Ooops sorry I didnt grasp what exactly functionality you are ranning after.
I do not have any idea how to force Serialization but you can force disposing followinf the pattern:
[code]
public class A : IDisposable
{
public A()
{}
virtual public void Dispose()
{
Exception ex = new Exception("No Dispose implemented, blah blah ...");
throw ex;
}
}
public class B : A
{
public B()
{}
public void Dispose()
{
}
}
[/code]
PetarPetrov at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Remoting and Runtime Serialization...
# 3
Not by using attributes
The SerializableAttribute's inherited property is set to false, so the attribute is not added to any derived classes.
I haven't tried this, but if you're working with .Net 2.0 beta 2, the following topic may be useful:

http://msdn2.microsoft.com/library/3z3z5s6h(en-us,vs.80).aspx

Hope this helps,
Gary
taumuon at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Remoting and Runtime Serialization...

.NET Development

Site Classified