[Serializable] and generic inheritance

H

Herby

I have a class like the following:

using namespace System::Collections::Generics;

[Serializable]
public ref class StringMap : public Dictionary<String^, String^>
{
public:
};

But when deserializing, the framework throws an exception that no
default constructor could be found for class StringMap.

If i then modify the class to the following:

[Serializable]
public ref class StringMap
{
public:

protected:

Dictionary<String^, String^> mMap;
};

then de-serializes ok. But I do not want a HAS_A relationship, for me
its more expressive to represent as a IS_A relationship. Also it would
be faster as no indirection.

Why will not the IS_A verison de-serialize correctly?

Thanks in advance.






};
 
H

Herby

The title should have said [Serializable] and generic inheritance.
Seems the square brackets caused something to happen?
 
H

Herby

So can nobody help me on this matter?
I assume if they were not intended to be inherited from they would be
sealed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top