类型的对象'Data.TimeLineChartedDay []'无法转换为类型“Data.TimeLineChartedDay []'? [英] Object of type 'Data.TimeLineChartedDay[]' cannot be converted to type 'Data.TimeLineChartedDay[]'?

查看:200
本文介绍了类型的对象'Data.TimeLineChartedDay []'无法转换为类型“Data.TimeLineChartedDay []'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误设计师在VS2008:

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:

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这个错误发生如下: 我添加了一个书面的自我控制。 VS崩溃并显示以下消息:类TimeLineChartedDay没有标记为可序列化。我发现这个奇怪的,因为它是写在另一台机器,它没有抱怨的序列化的属性。我加了属性类的,并无意中发现了preivous提到的错误。

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.

推荐答案

您控制试图序列化类实例时,它可能是不应该的。

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

您也许应该补充 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 来暴露的属性 TimeLineDisplay

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

有关更具体的建议,请告诉我们您的控制。

For more specific advice, please show us your control.

这篇关于类型的对象'Data.TimeLineChartedDay []'无法转换为类型“Data.TimeLineChartedDay []'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆