473,320 Members | 1,978 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,320 software developers and data experts.

Circular References...

Tom
Let's assume I have the following libraries:

MainLib (DLL)
MyControl (.NET user control)

Now MyControl needs to call MainLib, so I have a reference to MainLib
in MyControl. Let's then assume that I want to put a new form
(MyNewForm) in MainLib, but this form requires MyControl (i.e. I will
drop a copy if MyControl onto the MyNewForm). This would require me to
put a reference to MyControl in MainLib. Now I have MainLib referencing
MyControl, and MyControl referencing Mainlib!

Would this kind of circular reference even work? My problem is in what
order would something like this be compiled? I would think I would
first have to compile MyControl, then MainLib; but as soon as I
recompile MainLib the reference to MainLib in MyControl is now not
'current'...

Ugh, it hurts my head just thinking about this... I suppose the better
way would just be to make MyNewForm into it's own DLL, but was
wondering if something like the above scenario would work or is it even
recommended?

Thanks.

Tom
Nov 21 '05 #1
2 1271
Tom,

It is definitely not recommended. You should put MyNewForm into
another assembly or in the same assembly that contains MyControl.

Brian

Tom wrote:
Let's assume I have the following libraries:

MainLib (DLL)
MyControl (.NET user control)

Now MyControl needs to call MainLib, so I have a reference to MainLib
in MyControl. Let's then assume that I want to put a new form
(MyNewForm) in MainLib, but this form requires MyControl (i.e. I will
drop a copy if MyControl onto the MyNewForm). This would require me to
put a reference to MyControl in MainLib. Now I have MainLib referencing
MyControl, and MyControl referencing Mainlib!

Would this kind of circular reference even work? My problem is in what
order would something like this be compiled? I would think I would
first have to compile MyControl, then MainLib; but as soon as I
recompile MainLib the reference to MainLib in MyControl is now not
'current'...

Ugh, it hurts my head just thinking about this... I suppose the better
way would just be to make MyNewForm into it's own DLL, but was
wondering if something like the above scenario would work or is it even
recommended?

Thanks.

Tom


Nov 21 '05 #2
"Tom" <to*@nospam.com> wrote in message
news:uW**************@TK2MSFTNGP15.phx.gbl...
MyControl needs to call MainLib, so I have a reference to MainLib
in MyControl. Let's then assume that I want to put a new form
(MyNewForm) in MainLib, but this form requires MyControl
(i.e. I will drop a copy if MyControl onto the MyNewForm).
This would require me to put a reference to MyControl in MainLib. .. . . Would this kind of circular reference even work?


No. Circular references aren't supported in VB.Net.

Look at Interfaces. Use these to define:
(a) what the Library looks like to /any/ control,
(b) what /every/ control looks like to the Library,
(c) (possibly even) what each control looks like to /another/ control.

Something like

Interface ILibrary
Public Sub Method1()
Public Sub Method2()
End Interface

Interface ICustomControl
Public Show Show()
Public Show ShowDialog()
End Interface

Place of all these Interfaces into a third, shared library that is
referenced by both of the other two. Now, your circular references
have been extracted into this third assembly - so no problem there -
and each object knows "enough" about the others (as defined in the
Interfaces) to get on with whatever they all need to do.

HTH,
Phill W.
Nov 21 '05 #3

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? ...
6
by: Stephen Robertson | last post by:
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)...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.