arul

arul

  • NA
  • 26
  • 0

Deserialization in NameObjectCollectionBase

Aug 24 2006 11:00 AM

Hi,

When deserializing a class derived from NameObjectCollectionBase using GetValue, the count property is returning NullReferenceException. I tried using IDeserializationCallBack delegate also. Still not able to get the count. Can anybody help me on this?

This is my code:

[Serializable]
public class CMessagePropertiesNSVOCollection:NameObjectCollectionBase
{
    /// Contains its implentations 
}


[Serializable]
public class CMessageProperties:ISerializable
{
CMessagePropertiesVOCollection objCMessagePropertiesVOCollection;
}

public CMessageProperties(SerializationInfo info,StreamingContext context)
{
objCMessagePropertiesVOCollection= (CMessagePropertiesVOCollection)info.GetValue("nscollection", objCMessagePropertiesVOCollection.GetType()); 

int nCount = objCMessagePropertiesVOCollection.Count;// This returns NullReferenceException
}

public void GetObjectData(SerializationInfo info,StreamingContext context) 
{    
info.AddValue("nscollection", objCMessagePropertiesNSVOCollection); 
}

public long InitialisePipelineComponent(string sComponentIdentifier)
{
CMessagePropertiesData  objCMessagePropertiesData=new CMessagePropertiesData();

lResult=objCMessagePropertiesData.GetMessageNamespace(sComponentIdentifier,out objCMessagePropertiesNSVOCollection);
}


Regards,
Arul