Faced the problem that you need to write data to a binary file in one project, and read them from another project. When trying to do this, the program issued an error: "Unhandled type exception" System.Runtime.Serialization.SerializationException "in mscorlib.dll
Additional information: Could not find assembly "Discount1, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null". "
I give the code where I write the data to the file.
BinaryFormatter formatter = new BinaryFormatter(); FileStream fs; fs = new FileStream("2.dat", FileMode.Open, FileAccess.Write); formatter.Serialize(fs, shoppers); fs.Close(); Console.WriteLine("#МАСССИВ ОБЪЕКТОВ СЕРИАЛИЗОВАН#"); Now the code where I read data from another project, before that, transferred the file with data from the old project to the new one:
BinaryFormatter formatter1 = new BinaryFormatter(); FileStream fs1; fs1 = new FileStream("2.dat", FileMode.Open, FileAccess.Read); Nodes[] shoppers1 = (Nodes[])formatter1.Deserialize(fs1); foreach (Nodes n in shoppers1) { Console.Write(n.Name + " "); Console.Write(n.Surname + " "); Console.Write(n.Lastname + " "); if (n is NewNodes) Console.Write(n.PhoneNumber()); Console.WriteLine(); } fs1.Close();