Click here to Skip to main content
15,921,837 members
Home / Discussions / C#
   

C#

 
GeneralRe: Close MessageBox automaticly Pin
pcaeiro22-Mar-08 5:30
pcaeiro22-Mar-08 5:30 
QuestionHow to obtain external facing IP Address in C# Form Pin
PsychRich20-Mar-08 11:59
PsychRich20-Mar-08 11:59 
Questionhow to find location of an object Pin
netJP12L20-Mar-08 11:52
netJP12L20-Mar-08 11:52 
AnswerRe: how to find location of an object Pin
J$20-Mar-08 12:17
J$20-Mar-08 12:17 
AnswerRe: how to find location of an object Pin
Christian Graus20-Mar-08 12:54
protectorChristian Graus20-Mar-08 12:54 
AnswerRe: how to find location of an object Pin
Derek Bartram21-Mar-08 15:47
Derek Bartram21-Mar-08 15:47 
GeneralUpdating db using command builder or manualy Pin
baranils20-Mar-08 10:01
baranils20-Mar-08 10:01 
GeneralC# Object Serialization Problem Pin
Jammer20-Mar-08 10:01
Jammer20-Mar-08 10:01 
Hi All,

I posted about this a couple of days ago and I'm still trying to solve the problem. I just can't see what is different between my two uses of the same serialization class I've written (DataBaseStorage), one works the other doesn't.

I have a custom ObservableCollection defined that is marked as [Serializable] and implements all the required things (it works!):

[Serializable()]
public class FileInformation : ISerializable
{<snipped>


FileInformation also contains:

public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{<snipped>


I've hard coded a save into a class that builds a list of local files and this use of my serialization class works without any problems. In this class I create a new instance of my FileInformation collection using:

ObservableCollection<FileInformation> Database = new ObservableCollection<FileInformation>();


This class then goes off and does its thing to populate that collection then as I said above I have hard coded this save operation before returning the collection to my main window:

DataBaseStorage savedata = new DataBaseStorage();
savedata.SaveDatabaseData(@"App_Data\TestSaveLatest.dat", Database);
return Database;


The returned collection is then bound to a xamDataGrid (a WPF datagrid made by Infragistics). I can also start my app in debug mode and load this hard coded saved file back into the interface using my deserialize method in DataBaseStorage. The exception on the serialize method only happens when I try to save via the interface. The code there looks like:

if (fd.DialogResult == true)
{
    string fileToSaveToo = fd.cmbFilePicker.Text;
    DataBaseStorage savedata = new DataBaseStorage();
    savedata.SaveDatabaseData(fileToSaveToo, database);
    SampleSortMainScreen.Opacity = 1.0;
}


This is a bit of code from a button click bound to the interface using CommandBindings. When it hits the serialize line here:

public void SaveDatabaseData(string filename, ObservableCollection<fileinformation> objectToSerialize)
{
    Stream stream = File.Open(filename, FileMode.Create);
    BinaryFormatter bFormatter = new BinaryFormatter();
    bFormatter.Serialize(stream, objectToSerialize);
    stream.Close();
}</fileinformation>


I get the exception:

Type 'System.Collections.Specialized.CollectionChangedEventManager' in Assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.


I'm not entirely sure what this exception is telling me to be honest, I've googled it read as much as I can find about object serialization and the pitfalls that come from serializing events (there aren't any events tied to my FileInformation class. My dev has ground to a halt at the moment. I'm new to C# and .NET and this has me completely stumped. Am I doing something really daft like trying to serialize the WindowsBase assembly?

Thanks for any help folks, I'm now going slowly mad and round and round in circles looking for info on the web.

Jammer

Going where everyone here has gone before! Smile | :)
My Blog

GeneralRe: C# Object Serialization Problem Pin
ChrisKo20-Mar-08 11:19
ChrisKo20-Mar-08 11:19 
GeneralRe: C# Object Serialization Problem Pin
Jammer20-Mar-08 12:44
Jammer20-Mar-08 12:44 
QuestionHow to receive messages on the same socket sent from multiple UDP client using different ports? Pin
gix6520-Mar-08 8:43
gix6520-Mar-08 8:43 
GeneralRe: How to receive messages on the same socket sent from multiple UDP client using different ports? Pin
Paul Conrad21-Mar-08 10:04
professionalPaul Conrad21-Mar-08 10:04 
GeneralRecursive Generics for Fluent Interfaces [modified] Pin
TWang20-Mar-08 8:16
TWang20-Mar-08 8:16 
GeneralInstantiating Array of objects. Pin
Ravi Mahavrathayajula20-Mar-08 7:29
Ravi Mahavrathayajula20-Mar-08 7:29 
GeneralRe: Instantiating Array of objects. Pin
Russell Jones20-Mar-08 7:51
Russell Jones20-Mar-08 7:51 
GeneralRe: Instantiating Array of objects. Pin
Ravi Mahavrathayajula20-Mar-08 7:59
Ravi Mahavrathayajula20-Mar-08 7:59 
GeneralC# Used to send E-mail Pin
w20920-Mar-08 6:56
w20920-Mar-08 6:56 
GeneralRe: C# Used to send E-mail Pin
J4amieC20-Mar-08 7:20
J4amieC20-Mar-08 7:20 
GeneralRe: C# Used to send E-mail Pin
led mike20-Mar-08 8:16
led mike20-Mar-08 8:16 
QuestionCrystal reports with dynamic databases? Pin
Tammy Meister20-Mar-08 6:06
Tammy Meister20-Mar-08 6:06 
GeneralRe: Crystal reports with dynamic databases? Pin
Paul Conrad21-Mar-08 10:05
professionalPaul Conrad21-Mar-08 10:05 
Question[Message Deleted] Pin
Ravi Mahavrathayajula20-Mar-08 5:43
Ravi Mahavrathayajula20-Mar-08 5:43 
GeneralRe: Initializing the value of a 1d string to 2d string. Pin
CPallini20-Mar-08 5:49
mveCPallini20-Mar-08 5:49 
General[Message Deleted] Pin
Ravi Mahavrathayajula20-Mar-08 6:12
Ravi Mahavrathayajula20-Mar-08 6:12 
QuestionRe: Initializing the value of a 1d string to 2d string. Pin
CPallini20-Mar-08 6:46
mveCPallini20-Mar-08 6:46 

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.