Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is it possible to sort of embed an assembly within another assembly" Pin
#realJSOP8-Oct-08 4:47
mve#realJSOP8-Oct-08 4:47 
GeneralRe: Is it possible to sort of embed an assembly within another assembly" Pin
Member 30621768-Oct-08 4:51
Member 30621768-Oct-08 4:51 
GeneralRe: Is it possible to sort of embed an assembly within another assembly" Pin
Ashfield8-Oct-08 4:58
Ashfield8-Oct-08 4:58 
GeneralRe: Is it possible to sort of embed an assembly within another assembly" Pin
#realJSOP8-Oct-08 5:05
mve#realJSOP8-Oct-08 5:05 
AnswerRe: Is it possible to sort of embed an assembly within another assembly" Pin
Ennis Ray Lynch, Jr.8-Oct-08 5:18
Ennis Ray Lynch, Jr.8-Oct-08 5:18 
AnswerRe: Is it possible to sort of embed an assembly within another assembly" Pin
PIEBALDconsult8-Oct-08 5:19
mvePIEBALDconsult8-Oct-08 5:19 
AnswerRe: Is it possible to sort of embed an assembly within another assembly" Pin
teejayem8-Oct-08 8:34
teejayem8-Oct-08 8:34 
QuestionBinaryFormatter: Serializing an object's base class Pin
mav.northwind8-Oct-08 4:01
mav.northwind8-Oct-08 4:01 
Hi!

I just stumbled over an unexpected behaviour when trying to serialize a derived class using a BinaryFormatter, I guess the best is to show in code:
//for this sample I have 2 classes:
// [Serializable] class Animal
// and
// class Dog : Animal
// (not serializable)
Animal a = new Animal();
Dog d = new Dog();
Animal dogAsAnimal = d as Animal;

BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(serializationStream, a); // works
// bf.Serialize(serializationStream, d); // throws an exception because Dog is not Serializable
bf.Serialize(serializationStream, dogAsAnimal); // <- throws exception as well
I can't really understand why the last line is trying to serialize the object as Dog instead of Animal - is there any way to keep BinaryFormatter from doing this (short of adding a copy constructor to Animal and actually creating a new object)?

Thanks in advance!

Regards,
mav

--
Black holes are the places where God divided by 0...

AnswerRe: BinaryFormatter: Serializing an object's base class Pin
PIEBALDconsult8-Oct-08 4:07
mvePIEBALDconsult8-Oct-08 4:07 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
mav.northwind8-Oct-08 4:12
mav.northwind8-Oct-08 4:12 
AnswerRe: BinaryFormatter: Serializing an object's base class Pin
#realJSOP8-Oct-08 4:17
mve#realJSOP8-Oct-08 4:17 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
mav.northwind8-Oct-08 4:31
mav.northwind8-Oct-08 4:31 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
#realJSOP8-Oct-08 4:46
mve#realJSOP8-Oct-08 4:46 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Dan Neely8-Oct-08 5:49
Dan Neely8-Oct-08 5:49 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
mav.northwind8-Oct-08 9:01
mav.northwind8-Oct-08 9:01 
AnswerRe: BinaryFormatter: Serializing an object's base class Pin
Ennis Ray Lynch, Jr.8-Oct-08 5:20
Ennis Ray Lynch, Jr.8-Oct-08 5:20 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Mark Salsbery8-Oct-08 7:51
Mark Salsbery8-Oct-08 7:51 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Ennis Ray Lynch, Jr.8-Oct-08 8:45
Ennis Ray Lynch, Jr.8-Oct-08 8:45 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Mark Salsbery8-Oct-08 9:21
Mark Salsbery8-Oct-08 9:21 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Ennis Ray Lynch, Jr.8-Oct-08 9:39
Ennis Ray Lynch, Jr.8-Oct-08 9:39 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Mark Salsbery8-Oct-08 9:42
Mark Salsbery8-Oct-08 9:42 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Mark Salsbery8-Oct-08 9:53
Mark Salsbery8-Oct-08 9:53 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Ennis Ray Lynch, Jr.8-Oct-08 10:03
Ennis Ray Lynch, Jr.8-Oct-08 10:03 
GeneralRe: BinaryFormatter: Serializing an object's base class Pin
Mark Salsbery8-Oct-08 10:34
Mark Salsbery8-Oct-08 10:34 
AnswerRe: BinaryFormatter: Serializing an object's base class Pin
Giorgi Dalakishvili8-Oct-08 7:35
mentorGiorgi Dalakishvili8-Oct-08 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.