[Mono-list] Serializable object with Non-Serializable Fields --> SerializationException

Jacek Rużyczka stacheldraht at interia.pl
Wed Jun 2 09:58:50 EDT 2010


Am Mittwoch 02 Juni 2010 15:49:51 schrieb Robert Jordan:
> It's neither [Serializable] nor MarshalByRefObject:
> 
I've already removed [Serializable]. Sorry. :-(

> This is simply doomed to fails. DBConnection should be split
> in 2 parts: one that can be safely set from the client
> side (e.g. the connection string and other basic parameters)
> and one that does the rest on the server (creating the
> actual DB connection etc.).
> 
I've now found out a solution: The whole serializing stuff was because the 
DBConnectionHandler was generated on the client side and then passed to the 
PrintReceipt object, which in turn requires serialization. This was done 
intentionally to make the remote server as slim as possible. But I didn't take 
the side affects into account.

Now my class looks like this:

	public class PrintReceipt : MarshalByRefObject, IBatchJob
	{
		private DBConnectionHandler handler;
		private string              uri         = "";
		private string              description = "Beleg (ausgenommen Mahnung) 
erstellen";
		
		public PrintReceipt()
		{
			if (ServerInfo.isVerbose) Console.WriteLine
				(DateTime.Now.ToString() +  ": Serverobjekt PrintReceipt initialisiert.");
		}
		
		public string URI {
			get {
				return this.uri;
			}
			set {
				this.uri = value;
			}
		}
		
		public string Description {
			get {
				return this.description;
			}
		}
		
		public string [] BackendConnectionParameters {
			set {
				this.handler = new DBConnectionHandler(value);
			}
		}

		// Remainder omitted.
	}

Thank you very much for your hints.

Regards
Jacek Rużyczka

----------------------------------------------------------------------
Chcesz aparat fotograficzny? U nas mozesz go wygrac!
Sprawdz >>> http://linkint.pl/f2709



More information about the Mono-list mailing list