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

Robert Jordan robertj at gmx.net
Wed Jun 2 09:49:51 EDT 2010


Hey,

On 02.06.2010 15:23, Jacek Rużyczka wrote:
> Am Mittwoch 02 Juni 2010 14:46:07 schrieb Robert Jordan:
>> Where are you setting this property? How is DBConnectionHandler
>> implemented.
>>
> This is the DBConnectionHandler:

It's neither [Serializable] nor MarshalByRefObject:

> 	///<summary>
> 	/// The database connection handler used for batch jobs.
> 	///</summary>
> 	public class DBConnectionHandler : ICloneable

... but it is exposed by PrintReceipt:

> 	public class PrintReceipt : MarshalByRefObject, IBatchJob
> 	{
> 		[NonSerialized]
> 		private DBConnectionHandler handler;

... via this property:

> 		public DBConnectionHandler BackendConnectionHandler {
> 			set {
> 				this.handler = value;
> 			}
> 		}

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.).

Robert



More information about the Mono-list mailing list