UserControl和实体出现问题 [英] Problem with UserControl and Entity

查看:109
本文介绍了UserControl和实体出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是我想像Property一样在UserConcol中使用此Entity;我对List有问题.有关信息,我将[Serializable]放在LienNoeud List上.

这是我的实体:

The problem is that I want to use this Entity in UserConcol like Property; I have a problem with List. For information, I put [Serializable] on LienNoeud List.

This is my entity:

[Serializable]
public class NoeudEntity
{
    private RectangleNode m_Noeud = new RectangleNode();
    private String m_Nom;
    private String m_NoeudID;
    private List<LienEntity> m_LienNoeud;
    private EEtat m_Etat = new EEtat();

    public NoeudEntity()
    {
        m_LienNoeud = new List<LienEntity>();
    }

    public RectangleNode Noeud
    {
        get { return m_Noeud; }
        set { m_Noeud = value; }
    }

    public EEtat Etat
    {
        get { return m_Etat; }
        set { m_Etat = value; }
    }

    public List<LienEntity> LienNoeud
    {
        get { return m_LienNoeud; }
        set { m_LienNoeud = value; }
    }

    public String Nom
    {
        get { return m_Nom;}
        set { m_Nom = value;}
    }

    public String NoeudID
    {
        set { m_NoeudID = value; }
        get { return m_NoeudID; }
    }
}


这是我的UserControl中的财产:


It is my Property in my UserControl:

public NoeudEntity Noeud
{
    set { m_Noeud = value; }
    get { return m_Noeud; }
}



[我在这里移动了您的虚假答案,而不是简单地将其删除.]

大家好,
我回过头来解决我的问题,因为我找不到答案,但我认为
来自我的Entity中的List(它是[Serializable]).错误是:



[I moved your fake answer here instead of simply deleting it.]

Hi guys,
I come back on my problem because I''m not finding the answer but I think
that came from the List in my Entity (it is [Serializable]). The error is:

Object of type ''System.Collections.Generic.List`1[LienEntity]''
cannot be converted to type
''System.Collections.Generic.List`1[LienEntity]''.


我需要你的帮助
谢谢
jerem


I need your help
Thanks
jerem

推荐答案

您不会说错误是由于序列化,反序列化还是在设计器中.

因此,如果是反序列化.

如果程序集的版本号在序列化和反序列化之间更改,则会发生此类错误.即您先序列化,然后进行构建,然后反序列化.

尽管我认为问题已解决.

测试此方法的方法是运行您的应用程序,将其关闭,然后再次运行.如果仍然出现错误,那么这不是问题.

如果没有收到错误,请运行您的应用程序,将其关闭,进行构建,然后再次运行.如果收到错误,则这是最可能的原因.
解决方案是使用固定的版本号. (在AssemblyInfo.cs中,确保版本号看起来像1.0.1.0而不是1.0.1.*.
显然,您的数字可能与上面的示例有所不同,重要的是没有星号.

如果在设计器中,请 ^ ]可能会有帮助.
You do not say if the error is on serialization or deserialization or in the designer.

So if it is deserialization.

This sort of error did occur if the version number of your assembly changed between serialization and deserialization. i.e. you serialize, then do a build, then deserialize.

Although I thought that the problem had been resolved.

The way to test this is to run your app, close it, then run it again. If you still get the error then this is not the problem.

If you don''t get the error then run your app, close it, do a build, run it again. If you get the error then this is the most likely cause.

The solution is to have a fixed version number. (In AssemblyInfo.cs ensure that the version number looks like 1.0.1.0 rather than 1.0.1.*.
Obviously your numbers might be different from above example, the important thing is that there are no asterisks.

If it is in the designer, this[^] might help.


这篇关于UserControl和实体出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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