Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiii all...
I have asked that question before but didnt get the answer that y m asking that again...

I have an arraylist with user define data type...
and i need to send it trough LAN.
I am using WCF for communication and I know I have to convert arraylist to memorystream to send data...
I hve tried this method

Collapse | Copy Code

C#
ArrayList history = ie.getHistory();
BinaryFormatter f = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
f.Serialize(ms, history);


but I gives error because of user define data type...
C#
"Type 'UrlHistoryLibrary.STATURL' in Assembly 'UrlHistoryLibrary, Version=1.0.4146.25771, Culture=neutral, PublicKeyToken=null' is not marked as serializable."


help
thanks
Posted

1 solution

That's because STATURL is not marked serializable, as the exception says. You have to add the SerializableAttribute to your type. E.g.
C#
[Serializable]
public class MyClass
{
}


For more information on serialization in .NET see
Serialization[^]
Object Serialization in the .NET Framework[^]
 
Share this answer
 
Comments
Uday P.Singh 11-Sep-11 14:40pm    
my 5!
Simon Bang Terkildsen 11-Sep-11 15:26pm    
Thank you, Uday

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900