>using System; >using System.Collections.Generic; >using System.Linq; >using System.Text; >using System.Data.SqlClient; >using System.Collections; >using System.Data; > >namespace Marois.WorkIT.DataAccess >{ > [Serializable] > public class Address : DataClassBase > { > private int _AddressTypeKey = 0; > public int AddressTypeKey > { > get { return _AddressTypeKey; } > set { _AddressTypeKey = value; } > } > > private string _Street1 = string.Empty; > public string Street1 > { > get { return _Street1; } > set { _Street1 = value; } > } > > private string _Street2 = string.Empty; > public string Street2 > { > get { return _Street2; } > set { _Street2 = value; } > } > > private string _City = string.Empty; > public string City > { > get { return _City; } > set { _City = value; } > } > > private string _State = string.Empty; > public string State > { > get { return _State; } > set { _State = value; } > } > > private string _PostalCode = string.Empty; > public string PostalCode > { > get { return _PostalCode; } > set { _PostalCode = value; } > } > > public override void LoadData() > { > DataSet ds = AppDataAccess.GetAddresses(this.RecordId); > > if (ds != null && ds.Tables.Count > 0) > { > this.RecordId = Convert.ToInt32(ds.Tables[0].Rows[0]["AddressKey"]); > _AddressTypeKey = Convert.ToInt32(ds.Tables[0].Rows[0]["AddressTypeKey"]); > _Street1 = ds.Tables[0].Rows[0]["Street1"].ToString(); > _Street2 = ds.Tables[0].Rows[0]["Street2"].ToString(); > _City = ds.Tables[0].Rows[0]["City"].ToString(); > _State = ds.Tables[0].Rows[0]["State"].ToString(); > _PostalCode = ds.Tables[0].Rows[0]["PostalCode"].ToString(); > > } > > else > { > this.DataException = AppDataAccess.DataException; > } > } > > > public override void Delete() > { > SqlParameter pAddressKey = new SqlParameter("@AddessKey", this.RecordId); > ArrayList colParams = new ArrayList(); > colParams.Add(AddressTypeKey); > > AppDataAccess.ExecuteNonQuery("wit_DeleteAddress",colParams); > > if (AppDataAccess.DataException == null) > { > this.RecordId = 0; > _AddressTypeKey = 0; > > } > else > { > this.DataException = AppDataAccess.DataException; > } > > } > > public override bool SaveChanges() > { > bool RetVal = Validate(); > > if (RetVal) > { > string ProcName = string.Empty; > > SqlParameter pAddressKey = new SqlParameter("@AddressKey", 0); > > if (this.RecordId == 0) > { > pAddressKey.Direction = ParameterDirection.Output; > ProcName = "wit_AddAddress"; > } > else > { > > pAddressKey.Value = this.RecordId; > ProcName = "wit_UpdateAddress"; > } > > SqlParameter pAddressTypeKey = new SqlParameter("@AddressTypeKey",_AddressTypeKey); > SqlParameter pStreet1 = new SqlParameter("@Street1", _Street1); > SqlParameter pStreet2 = new SqlParameter("@Street2", _Street2); > SqlParameter pCity = new SqlParameter("@City", _City); > SqlParameter pState = new SqlParameter("@State", _State); > SqlParameter pPostalCode = new SqlParameter("@PostalCode", _PostalCode); > > ArrayList colParams = new ArrayList(); > colParams.Add(pAddressKey); > colParams.Add(pAddressTypeKey); > colParams.Add(pStreet1); > colParams.Add(pStreet2); > colParams.Add(pCity); > colParams.Add(pState); > colParams.Add(pPostalCode); > > AppDataAccess.ExecuteNonQuery(ProcName, colParams); > > if (AppDataAccess.DataException == null) > { > > if (pAddressKey.Direction == ParameterDirection.Output) > { > this.RecordId = Convert.ToInt32(pAddressKey.Value); > } > } > else > { > this.DataException = AppDataAccess.DataException; > } > } > > return RetVal; > } > > public override bool Validate() > { > bool bValid = true; > > if (_AddressTypeKey == 0) > { > bValid = false; > base.DataException = new DataValidationException("Address can not be empty"); > } > return bValid; > } > } >} >>
'System.Runtime.Serialization.SerializationException: Type 'Marois.WorkIT.DataAccess.Address' in Assembly 'DataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Marking it as serializable should get rid of that error but if any of the properties of the Address class were not serializable you may get a different error. Can you post the code for the class?>>>>>Failed to create component 'crlAddresses'. The error message follows: >>>>> >>>>> 'System.Runtime.Serialization.SerializationException: Type 'Marois.WorkIT.DataAccess.Address' in Assembly 'DataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. >>>>> >>>>> at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) >>>>> >>>>> at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) >>>>> >>>>> at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() >>>>> >>>>> at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) >>>>> >>>>> at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) >>>>> >>>>> at System.Runtime.Serialization.Formatters.Bina...' >>>>>