Re: Serialization and inheritance



That's a pity. Forces me to move my student class to the shared assembly, it
isn't neat, but it works.

Thanks for your fast reply,

Gerben.

"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23jTdGEt6FHA.3760@xxxxxxxxxxxxxxxxxxxxxxx
> Gerben,
>
> Unfortunately, no, you can not. You need to have a reference to the
> assembly that contains the type you are going to serialize so that the
> serialization framework will be able to load the appropriate type/field
> data for serialization.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "Gerben" <plzdonotreply@xxxxxxx> wrote in message
> news:dlfoav$iv$1@xxxxxxxxxxxxxxxxxxxxxxxxxx
>> Hello,
>>
>> I'm getting an error when I try to serialize a class in my project. Hope
>> someone can help me out:
>>
>> Shared assembly:
>>
>> [Serializable]
>> public abstract class Person
>> {
>> public int PersonData;
>> }
>>
>> Project1
>>
>> [Serializable]
>> public class Student : Person
>> {
>>
>> }
>>
>> Person person1 = new Student();
>>
>> Project2:
>>
>> I like to serialize person1 (using .net remoting) so I can use that
>> object in this project. Project2 only knows the person class, but that is
>> enough since I only need to access PersonData and nothing else. When I
>> try this i'm getting a serializable exception that says that project2
>> cannot find Project1. But I don't want to include project1 or the student
>> class. Is there a way to solve this / can I tell Student to only
>> serialize the Person data in some way?
>>
>> greets,
>>
>> Gerben.
>>
>
>


.



Relevant Pages

  • Re: Elimnating namespace in XML
    ... public class Student ... // Create an instance of the object to serialize ... Student student = new Student; ... // Serialize the object with our own namespaces ...
    (microsoft.public.dotnet.framework)
  • Re: How to write Array of Object to a file?
    ... not even to your own posts. ... // method will take the student list and save it to student.dat file. ... ObjectOutputStream objOut = new ObjectOutputStream(new ... Without the source for the Student class in hand we have to guess why you cannot serialize the class. ...
    (comp.lang.java)
  • Re: How to write Array of Object to a file?
    ... public class WriteStudentData { ... // method will take the student list and save it to student.dat file. ... ObjectOutputStream objOut = new ObjectOutputStream(new ... Without the source for the Student class in hand we have to guess why you cannot serialize the class. ...
    (comp.lang.java)
  • Re: Serialization and inheritance
    ... serialization framework will be able to load the appropriate type/field data ... > I'm getting an error when I try to serialize a class in my project. ... > public class Student: Person ... > since I only need to access PersonData and nothing else. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Growing up gifted
    ... argument, evaluating evidence, properly citing works consulted, these ... should all be part of every class a student takes. ... Pity they aren't then. ...
    (soc.singles.moderated)