473,857 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 frmsearchresult s, 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 5090
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.googl e.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 frmsearchresult s, 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.googl e.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 frmsearchresult s, 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 frmdsearchresul t 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
(frmsearchresul t) project to the project (frmperson)

"Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message news:<eY******* *******@tk2msft ngp13.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.googl e.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 frmsearchresult s, 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 frmdsearchresul t 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(searc h) and frmperson(data) and frmsearchresult s 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***********@ SPAMsympaticoPL EASE.ca> wrote in message news:<uz******* ******@tk2msftn gp13.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.googl e.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 frmsearchresult s, 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.ShowSelected PersonButton.Cl ick += new
EventHandler(th is.ShowNewPerso nUsingSearchRes ult);
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.goo gle.com...
Alex,

Thanks for your reply...

Let me explain further. frmperson and frmdsearchresul t 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(searc h) and frmperson(data) and frmsearchresult s 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***********@ SPAMsympaticoPL EASE.ca> wrote in message

news:<uz******* ******@tk2msftn gp13.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.googl e.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 frmsearchresult s, 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.googl e.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 frmsearchresult s, 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.Display Using = 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
2851
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 semi-circular definitions and
2
7988
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 references when the circular reference is contained with in a collection class, specifically I am using a custom ArrayList object. I keep getting a StackOverFlow Exception from the XmlSerializer class when attempting the serialisation. The classes...
8
3507
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 to disk multiple times. Now I'm using just basic serialization as described in MSDN. Clearly, I need to stop serializing these parent references, but I do need to re-instate them to the proper objects when de-serializing. Can anyone help me with a...
12
7068
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 issues that I am not seeing (performance wise or garbage collection wise) with circular references? Thanks.
5
6854
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? One solution to the problem is to re-architect the solution. But, I dont want to do this as there are many modules in the project which are already developed and nearing the release.
2
2827
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 use the web service proxy client generated by visual studio. However, the default test harness provided by the .asmx file errors out because it seems to use XmlSerialization and cannot handle circular references. I understand that the...
5
3805
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 reference since one class would not be compiled unless other is compiled. This is kind of a deadlock. Isnt it ?
3
2934
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 better than the amount of errors I was originally getting on builds before I consilidated by UC's though :-) "Paul Hale" wrote:
2
1862
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 enumerate the AssemblyNames from the GetReferencedAssemblies() collection.
0
9923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10807
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9549
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7939
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7104
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5774
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.