Constructor on type 'MYCLASS' not found.

I have 7 classes.. Some of them inherited from non serializable object , some of other inherited from 3rd party components.

All of my classes have got [Serializable] attribute , ISerilazable interface and

ClassName(SerializationInfo info, StreamingContext context)

Most of them have got List of the other as property .

Altough everything fine I got error like that " Constructor on type 'myclass' not found."

I couldnt understand why

Thx for advices..



Answer this question

Constructor on type 'MYCLASS' not found.

  • Shildrak

    I could find source of problem but it seems a lot of problem will come .

    Im going to try to define my class hierarchy ...

    Class A: Container class ,It has got ListOfB and ListOfC and many other classes and global resources.. (Program.Form2 for example)

    Class B: Container class Has Got ListOfC and D

    Class C: Has Got Class A

    Class D: Has got Class B

    As you can see i have a lot cross references

    Scenerio 1: constitution of Class A

    1- Contruct Class A

    2- Load B to A

    a) Load C to B

    b) Load Another C to B

    3- Load Another B to A

    As you can see cascaded class constructions..

    .. I try to "Save" Class A to disk

    And i will "Load" it ..

    What is the best way for this requirement Am i on true way

    I m planning the observe "change paths of objects states" ..

    And I implement them on GetObjectData and Special Constructor of Class A


  • rnellis2002

    Sorry. with this information I am unable to see any problem

    Good luck



  • Biju S Melayil

    I haven't heard for Serialization Design Patterns but there is Memento GoF - take a look at http://www.dofactory.com/Patterns/PatternMemento.aspx

    hope this helps



  • Bill Foust

    I think that when you iterate through the types via reflection each type must implement a default constructor (without parameters).

    Stay cheerful,

    Dave


  • joss1974

    could you be more specific according me you have problem with one single class. Please check tha tyou have public constructor for that class

    If you keep experience this problem post class declaration here so we could help you.

    hope this helps



  • Koray Samsun

    Maybe someone says to me "these are "Serialization Design Patterns "

    Thx again ..

    May Maybe someone can show me "Serialization Design Patterns" ..

    Thx again..


  • Karrar

    My problem is more complicated i think i have to solve myself ..But i coudlnt understand why someone (like Microsoft :))

    doesnt write Serialization Framework (Library) ..

    I have to write my self as you see : But not simple as my code as ..

    public void GetObjectData(SerializationInfo info, StreamingContext context)

    {

    Type type = this.GetType();

    PropertyInfo[] ps= type.GetProperties();

    //FieldInfo[] fs = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);//type.GetFields();

    FieldInfo[] fs = type.GetFields();

    foreach (PropertyInfo p in ps)

    {

    if (!p.CanWrite) continue;

    info.AddValue(p.Name,p.GetValue(this, null));

    }

    foreach (FieldInfo f in fs)

    {

    if (!f.IsNotSerialized)

    info.AddValue(f.Name, f.GetValue(this));

    }

    }


  • Bruce Baker

    Oguz wrote:

    .. I try to "Save" Class A to disk

    And i will "Load" it ..

    From what I understand you need to implement serialization for your A class, is the only way you can save the object state to disk.Read this article on serialization, if you need more help on the subject just ask.



  • Constructor on type 'MYCLASS' not found.