StackOverflowException

Topics: Issues / bugs
Apr 4, 2012 at 8:28 AM
Edited Apr 4, 2012 at 8:30 AM

Hello I get an StackOverflowException in the DebugLogListener: At this Place:

 

public override void Write(ILog log, string message, LogEvent logEvent)
{
    string consoleMessage = string.Format("{0} => [{1}] {2}", DateTime.Now.ToString("hh:mm:ss:fff"),
      logEvent.ToString().ToUpper(), message);

...

 

The Methods OnDeserialization and CallOnDeserializationCallback called very very often. I think the consequence of an recursiv call.

Do you have any idea what i made wrong. Any tipps?

Coordinator
Apr 4, 2012 at 8:36 AM

I think it is not the logging that that is wrong, you are probably facing this issue:

http://catel.codeplex.com/workitem/7102

Apr 4, 2012 at 8:54 AM

I also think it is not the logging.

Maybe it is this issue. My Model is a Composite.

A Model has a list of Models and each Model has a Reference to the Parent which is also from the same Typ. 

Apr 4, 2012 at 8:56 AM

The Exception only occurs when i Register the Property in the DataobjectBase. When i implement a normal property i get no error.

Coordinator
Apr 4, 2012 at 9:07 AM

That's because only when they are known in the property bag (Containing all property values), they are backed up.

Apr 4, 2012 at 9:11 AM

 Ok. Is there a workaround or do i have to wait until the issue is solved?

Coordinator
Apr 4, 2012 at 9:13 AM

Well, the DOB does implement the IParent interface if I am not mistaken. What you can also do is implement the parent as wrapper (does making it a "regular" property, then it will not be backed up (which is what should happen)).

Apr 4, 2012 at 9:33 AM

Ok. Wrapper? Little Example?

Coordinator
Apr 4, 2012 at 9:38 AM

Try casting a child item to IParent interface. After deserializing or construction, it should be filled. If that doesn't work, go for the simple properties for now.

Apr 4, 2012 at 9:49 AM
After deserializing or construction, it should be filled. 

Do i have to fill it, or sould it filled automaticaly?

Sorry, at the moment its not clear for me, what i have to do.

Coordinator
Apr 4, 2012 at 10:19 AM

It should be filled automatically. If not, then I have to write docs (but it is a long time ago (3 years) when I wrote that part, so I don't know it out of my head).

Apr 4, 2012 at 12:33 PM
Edited Apr 4, 2012 at 12:34 PM

Ok its filled but only in constructor. When i fill the list not in the constructor i have set the Parent manual. Not so easy because the SetParent method in DataObjectBase is protected

In this way it works. I need an static method in MyModel.

MyModel:DataObjectbase
{
    ...

    protected static void SetParent(MyModel mm, IParent parent) 
    {
        mm.SetParent(parent);
    }
}


MyListModel : MyModel
{ 

...

public ObservableCollection MyModelList { get { return GetValue<ObservableCollection<MyModel>>(MyModelListProperty); } set { SetValue(MyModelListProperty, value); } } public static readonly PropertyData MyModelList= RegisterProperty("MyModelList", typeof(ObservableCollection<MyModel>)); public void Add(MyModel model) { SetParent(model,this); MyModelList.Add(model); } }

Maybe you have an better solution

Apr 4, 2012 at 2:29 PM

I had the same issue. In have a tree like model and in every model I want to keep a reference to it's parent. When I added this parent reference I got a stackoverflow during registration.

Now I have made my parent a "normal" property since it is not going to change in my case. I have added it to the constructor and set it there.

When I have a reference to a model I can now walk the tree back to the root.

Apr 16, 2012 at 6:38 AM

Yes. Like i say. Only in the constructor. When you add an object later you have to do that in the add method or on a property changed event.

Coordinator
Apr 17, 2012 at 8:19 AM

We are planning to take a look at this in 3.2.

Coordinator
Jul 2, 2012 at 5:40 PM

This issue should be solved. Can you please verify that it is fixed?