Problem with Object CloneProblem with Object Clone
Old forum URL: forums.lhotka.net/forums/t/827.aspx
Bonio posted on Sunday, August 06, 2006
I am getting a strange problem when I clone an object prior to saving. The error details are as follows:
Type 'System.Data.SqlClient.SqlConnection' in Assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Any ideas how I can fix this/get round it.
TIA
Bonio
hurcane replied on Sunday, August 06, 2006
SqlConnection objects cannot be serialized. You could mark the variable with the <NonSerialized> attribute, and your error will go away.
However, serialization only takes module class-level variables with it. A SqlConnection object declared at the class level is generally a sign of a poor design and will likely lead to bugs that are difficult to troubleshoot. If you follow the intent of the framework, database-specific objects should only be declared and used within the DataPortal_Xyz methods.
Copyright (c) Marimer LLC