473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

circular references

We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson
Nov 20 '05 #1
6 5044
First of all, i'm not really seeing a circular reference here. you have two
independant instances of frmperson.
Secondly, what is the problem? Circular references aren't inherantly bad. In
VB6 there was a problem because COM references aren't cleaned up until the
ref count for both objects drop (which never happens in a circular
dependancy unless you resort to some clever tricks), but with a garbage
collector, as long as both aren't reachable, the GC will still clean them
up.

-Rob Teixeira [MVP]

"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson

Nov 20 '05 #2
If you can't compile this project with Visual Studio - try SharpDevelop.
However, this is not the point of my remark.
Usually circular references - or perceived as circular - are indicating
design problems. You can consider for example passing frmsearchresult
selection (or which frmperson to new) back to original frmperson or its
parent, which will manage new instance. Maybe person who mentioned events
meant something like this. You can use events or direct properties for this.
And several other techniques. In case of events, you can invoke event
handler when selection changes in frmsearchresult. And handler will be set
by main controller of your application.
Would you care to explain more what is the problem? I might miss something.

HTH
Alex
"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson

Nov 20 '05 #3
Rob,

I agree.

But, let me explain further. frmperson and frmdsearchresult are
individual projects. I have a reference to frmsearchresult in
frmperson. When I try and set a reference to frmperson in
frmserachresult, I get the circular reference error.

The problem is that when I try and set a reference in the
(frmsearchresult) project to the project (frmperson)

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message news:<eY**************@tk2msftngp13.phx.gbl>...
First of all, i'm not really seeing a circular reference here. you have two
independant instances of frmperson.
Secondly, what is the problem? Circular references aren't inherantly bad. In
VB6 there was a problem because COM references aren't cleaned up until the
ref count for both objects drop (which never happens in a circular
dependancy unless you resort to some clever tricks), but with a garbage
collector, as long as both aren't reachable, the GC will still clean them
up.

-Rob Teixeira [MVP]

"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson

Nov 20 '05 #4
Alex,

Thanks for your reply...

Let me explain further. frmperson and frmdsearchresult are individual
projects. I have a reference to frmsearchresult in frmperson. When I
try and set a reference to frmperson in frmserachresult, I get the
circular reference error.

I whould like to keep the (search) frmperson available is the user
wants to alter the search. This design will allow any number of
frmperson(search) and frmperson(data) and frmsearchresults to be open
at anytime.

I think you are on the right track with the event handlers. If it
will work, I am just not sure how to implement.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:<uz*************@tk2msftngp13.phx.gbl>...
If you can't compile this project with Visual Studio - try SharpDevelop.
However, this is not the point of my remark.
Usually circular references - or perceived as circular - are indicating
design problems. You can consider for example passing frmsearchresult
selection (or which frmperson to new) back to original frmperson or its
parent, which will manage new instance. Maybe person who mentioned events
meant something like this. You can use events or direct properties for this.
And several other techniques. In case of events, you can invoke event
handler when selection changes in frmsearchresult. And handler will be set
by main controller of your application.
Would you care to explain more what is the problem? I might miss something.

HTH
Alex
"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson

Nov 20 '05 #5
Do you need to reference frmperson from frmsearchresult?
If search is done from frmperson, you can show frmsearchresult and get
selection from there. Suppose, you have button on frmsearchresult, which
must show new frmperson. If you want to leave frmsearchresult on screen and
show new frmperson at the same time, you can inform main frmperson that new
one should be created by setting button click event handler to method in
frmperson:

frmperson code:
....
frmsearchresult fs = new frmsearchresult(...);
fs.ShowSelectedPersonButton.Click += new
EventHandler(this.ShowNewPersonUsingSearchResult);
fs.Show();
....

In the event handler you can use some property or method in frmsearchresult
to get person id or whatever you use to init frmPerson.
I see no need to make circular reference in this case.
You might want to check also Observer pattern if you want to implement more
complex scheme of interaction:
http://msdn.microsoft.com/architectu...esObserver.asp

HTH
Alex

"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
Alex,

Thanks for your reply...

Let me explain further. frmperson and frmdsearchresult are individual
projects. I have a reference to frmsearchresult in frmperson. When I
try and set a reference to frmperson in frmserachresult, I get the
circular reference error.

I whould like to keep the (search) frmperson available is the user
wants to alter the search. This design will allow any number of
frmperson(search) and frmperson(data) and frmsearchresults to be open
at anytime.

I think you are on the right track with the event handlers. If it
will work, I am just not sure how to implement.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message

news:<uz*************@tk2msftngp13.phx.gbl>...
If you can't compile this project with Visual Studio - try SharpDevelop.
However, this is not the point of my remark.
Usually circular references - or perceived as circular - are indicating
design problems. You can consider for example passing frmsearchresult
selection (or which frmperson to new) back to original frmperson or its
parent, which will manage new instance. Maybe person who mentioned events meant something like this. You can use events or direct properties for this. And several other techniques. In case of events, you can invoke event
handler when selection changes in frmsearchresult. And handler will be set by main controller of your application.
Would you care to explain more what is the problem? I might miss something.
HTH
Alex
"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.

Idea...

We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.

Problem...

We will get a circular reference between frmperson and
frmsearchresult.

I have read the mention of events as a workaround. Could someone
please elaborate on how the use of events could possibly help us in
our situation?

Or, is there another way?

Thank you very much,

Dawn Robertson

Nov 20 '05 #6
"Stephen Robertson" <ea***********@yahoo.com> wrote in message
news:c3************************@posting.google.com ...
.. . .
We have frmmain calling frmperson (dim f as new frmperson) in
search (no record) mode. When the search is executed, frmperson
calls frmsearchresult (dim f as new frmsearchresult) which is a listing
of persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting record.


Would it not be better to pass frmSearchResult a reference to the
existing frmPerson form (object), and allow the results for to reuse this,
rather than creating a new form every time, as in

[frmPerson]
Sub DoSearch( ... ) Handles ...
Dim oSearch as New frmSearchResult
oSearch.DisplayUsing = Me
oSearch.Show[Dialog]()
End Sub

[frmSearchResult]

' ONLY as an example
Public DisplayUsing as frmPerson = Nothing

Sub RowSelected() Handles ...
If ( Me.DisplayUsing is Nothing ) Then
Me.DisplayUsing = New frmPerson
End If
Me.DisplayUsing.Show()
. . .
End Sub

HTH,
Phill W.
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Kiuhnm | last post by:
Is there an elegant way to deal with semi-circular definitions? Semi-circular definition: A { B }; B { *A }; Circular reference: A { *B }; B { *A }; The problems arise when there are more...
2
by: Earth Worm Jim | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular...
8
by: Eric Eggermann | last post by:
I'm having a problem with really large file sizes when serializing the classes that describe my little document. There are some circular references which result in the same object getting written...
12
by: Frank Rizzo | last post by:
I have a circular reference between 2 classes in the same project (i.e. each class refers to the other). The app runs fine and I am seeing no issues, which kind of surprised me. Are there any...
5
by: Gos | last post by:
Hi, It is known that .NET does not allow us to add circular references. Is there a way to workaround this problem by late-binding the objects at run time? Will this create any other problems? ...
2
by: Lapu-Lapu | last post by:
I have authored a web service using ASP 2.0. The web services return objects that use generics and that also contain circular references. Programmatically, everything works well, as long as you...
5
by: Madhur | last post by:
Hello If I define two classes in the same cs file. And in each class, I define the object of other class as a member. Can anyone explain me how .NET or its compiler will resolve this kind of...
3
by: =?Utf-8?B?UGF1bCBIYWxl?= | last post by:
Moving all User Controls to a single directory has solved my problem - Thanks Eliyahu. That said, I still got one Circular ref error yesterday, rebuilt again and the build was fine? Far far...
2
by: Dansk | last post by:
Hi all, I am currently writing some code that explores assemblies dependencies. I start loading the first assembly with Assmebly.LoadFrom which gives me an Assembly instance. Then, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.