Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: Detecting when multiple BackgroundWorkers are finished Pin
led mike23-Jul-07 5:02
led mike23-Jul-07 5:02 
QuestionFocusable Panel Pin
Sukhjinder_K20-Jul-07 7:14
Sukhjinder_K20-Jul-07 7:14 
AnswerRe: Focusable Panel Pin
Judah Gabriel Himango20-Jul-07 7:29
sponsorJudah Gabriel Himango20-Jul-07 7:29 
GeneralRe: Focusable Panel Pin
Sukhjinder_K20-Jul-07 7:39
Sukhjinder_K20-Jul-07 7:39 
QuestionSerialization of arrays Pin
Rudolf Jan20-Jul-07 7:05
Rudolf Jan20-Jul-07 7:05 
AnswerRe: Serialization of arrays Pin
led mike20-Jul-07 7:14
led mike20-Jul-07 7:14 
GeneralRe: Serialization of arrays Pin
Rudolf Jan23-Jul-07 2:56
Rudolf Jan23-Jul-07 2:56 
GeneralRe: Serialization of arrays Pin
Rudolf Jan23-Jul-07 8:03
Rudolf Jan23-Jul-07 8:03 
I did some additional tests. It seems the problem has nothing to do with lists, but possibly there is a bug in .NET. If I try to serialize two objects of the same type, I get the error message that I cannot serialize the same object twice. It mey be an error in the translation of the .NET error messages. I cannot check that. I have a Dutch Windows version trepresenting all .NET errors in Dutch.

Below the code to demonstrate the problem:

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;
using System.Runtime.Serialization.Formatters.Soap;

namespace Serialization
	{
	// Create a class to include in the list
	[Serializable]
	public class MyObject:ISerializable
		{
		public Int32 idx=0;

		public MyObject(Int32 i)
			{
			idx=i;
			}

		internal MyObject(SerializationInfo info,StreamingContext context)
			{
			idx=info.GetInt32("Idx");
			}

		public virtual void GetObjectData(SerializationInfo info,StreamingContext context)
			{
			info.AddValue("Idx",idx);
			}
		}

	[Serializable]
	class ObjectList: ISerializable
		{
		MyObject object1;
		MyObject object2;

		public ObjectList()
			{
			object1=new MyObject(1);
			object2=new MyObject(2);
			}

		protected ObjectList(SerializationInfo info,StreamingContext context)
			{
			object1=new MyObject(info,context);
			object2=new MyObject(info,context);
			}

		public virtual void GetObjectData(SerializationInfo info,StreamingContext context)
			{
			object1.GetObjectData(info,context);
			// here (netx statement) i get an exception, cmplaining i cannot serialize 
			//the same object twice, though the objects are clearly not the same.
			object2.GetObjectData(info,context);
			}
		}

	class Program
		{
		static void Main(string[] args)
			{
			ObjectList MyObjectList=new ObjectList();
			FileStream WriteStream=new FileStream("test.xml",FileMode.Create); 
			SoapFormatter bfor=new SoapFormatter();
			MyObject Object1=new MyObject(1);
			MyObject object2=new MyObject(2);
			bfor.Serialize(WriteStream,MyObjectList);
			}
		}
	}


Rudolf Heijink
GeneralRe: Serialization of arrays Pin
led mike23-Jul-07 8:23
led mike23-Jul-07 8:23 
GeneralRe: Serialization of arrays Pin
Rudolf Jan5-Aug-07 10:07
Rudolf Jan5-Aug-07 10:07 
QuestionShowing form window above task bar. Pin
kaleem tarar20-Jul-07 6:48
kaleem tarar20-Jul-07 6:48 
QuestionHow to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 6:35
imagic20-Jul-07 6:35 
AnswerRe: How to install an addin for Visual Studio .NET 2005 Pin
Judah Gabriel Himango20-Jul-07 7:31
sponsorJudah Gabriel Himango20-Jul-07 7:31 
GeneralRe: How to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 18:53
imagic20-Jul-07 18:53 
GeneralRe: How to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 22:49
imagic20-Jul-07 22:49 
QuestionReplacing pictures Pin
eskape1920-Jul-07 5:30
eskape1920-Jul-07 5:30 
AnswerRe: Replacing pictures Pin
Luc Pattyn20-Jul-07 5:56
sitebuilderLuc Pattyn20-Jul-07 5:56 
QuestionUpload a file to my server Pin
Raymond_P*20-Jul-07 5:07
Raymond_P*20-Jul-07 5:07 
AnswerRe: Upload a file to my server Pin
led mike20-Jul-07 7:04
led mike20-Jul-07 7:04 
GeneralRe: Upload a file to my server Pin
Raymond_P*20-Jul-07 7:08
Raymond_P*20-Jul-07 7:08 
GeneralRe: Upload a file to my server Pin
led mike20-Jul-07 7:11
led mike20-Jul-07 7:11 
GeneralRe: Upload a file to my server Pin
Raymond_P*20-Jul-07 7:33
Raymond_P*20-Jul-07 7:33 
GeneralRe: Upload a file to my server Pin
led mike20-Jul-07 8:01
led mike20-Jul-07 8:01 
QuestionC# wrapper for Robocopy.exe Pin
Harkamal Singh20-Jul-07 4:07
Harkamal Singh20-Jul-07 4:07 
AnswerRe: C# wrapper for Robocopy.exe Pin
led mike20-Jul-07 7:03
led mike20-Jul-07 7:03 

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.