Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / January 2007

Tip: Looking for answers? Try searching our database.

Understand cicular referencing properties!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Özden Irmak - 31 Dec 2006 00:25 GMT
Hello,

In my task, I'm scanning all properties of an object and picking up to show
their names in a treeview if it fits some criterias I defined. When
scanning, I've a problem which causes stack overflow error...

This happens when a class does have a circular reference...The best sample
for this can be the treenode class. This class has a refence to it's parent
node also to the treeview control itself. When scanning treenode class,
because of this circular reference, I keep getting back to treeview control
and start scannig all of it's properties which happens infinite times and at
last getting a stack overflow error. The WindowsForms serializer somehow
understands these kind of circular references and instead of trying to
serialize that property, it just sets a reference to the original class.

I'm trying to detect the same sitution and stop going through these circular
referenced properties. Is there any method in .Net to let me understand this
or any method anybody knows?

Thanks in advance...

Regards,

Özden
Mario Vázquez - 31 Dec 2006 07:47 GMT
Hi Özden,

I suppose you are trying to load recursively the hole treeview. Why you
don't try to load only the first level of the current node?. In that way, it
does'nt matter if you (or somebody) open a node which it was yet visited,
because only the next level will be charged.
Another aproach it will be to determine programatically with the
ReferenceEquals method if the property you are trying to inspect it's
equivalent to a parent object, and cancel the inspection in that case...

Regards,
Mario Vazquez

> Hello,
>
[quoted text clipped - 21 lines]
>
> Özden
Özden Irmak - 01 Jan 2007 11:52 GMT
Hello Mario,

Thank you very much for the "ReferenceEquals" tip, it'll be really helpfull
for me.

I think after "ReferenceEquals", feed as needed won't be necessary for me.
Although my code still doesn't work as expected, it seems there are other
problems than self referencing.

Thank you very much again and wish a happy new year for you...

Regards,

Özden

> Hi Özden,
>
[quoted text clipped - 34 lines]
>>
>> Özden

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.