Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object of type 'Data.TimeLineChartedDay[]' cannot be converted to type 'Data.TimeLineChartedDay[]'?

I'm getting the following Designer Error in VS2008 :

 Object of type 'Data.TimeLineChartedDay[]' cannot be 
 converted to type 'Data.TimeLineChartedDay[]'.  

???

public class TimeLineDisplay     
{
    private List<TimeLineChartedDay> chartedDays = new List<TimeLineChartedDay>();

    public List<TimeLineChartedDay> ChartedDays         
    {
        get { return chartedDays; }
        set { chartedDays = value;  }
    }
}

[Serializable]
public class TimeLineChartedDay
{
    private DateTime date;
    private int chartValue;

    public DateTime Date
    {
        get { return date; }
        set { date = value; }
    }

    public int ChartValue
    {
        get { return chartValue; }
        set { chartValue = value; }
    }

    public TimeLineChartedDay()
    { 

    }
}

VS STACK :

    at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
    at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
    at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)
    at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
    at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
    at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
    at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
    at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
    at System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
    at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
    at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
    at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)  

Previous to this error the following occured : I added a self written control. VS crashed with the following message: "Class TimeLineChartedDay is not marked as serializable". I found this strange because it was written on another machine, which didn't complain about the 'Serializable' attribute. I added the attribute to the class, and stumbled on the preivous mentioned error.

like image 795
Run CMD Avatar asked Dec 15 '10 16:12

Run CMD


2 Answers

Your control is trying to serialize the class instance when it probably shouldn't.

You should probably add [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] to the property that exposes the TimeLineDisplay.

For more specific advice, please show us your control.

like image 199
SLaks Avatar answered Sep 23 '22 01:09

SLaks


I had the same problem with a custom control. Though adding the control via designer failed with the message "Class is not marked as serializable", it added a variable to the Designer.cs file and an entry the .resx file.

I had to remove those entries by hand and everything worked well. For the resx file I did right click -> Open with -> Source Editor and searched for entries containing the class name and removed them.

like image 43
boFFeL Avatar answered Sep 24 '22 01:09

boFFeL