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

Circular References! Big Problem!

pnp
I'm developing an app (in C #) that uses 2 usercontrols that must be in
different dll's.
The problem is that each one needs to use the other, so as a result I get a
circular reference error when I try to add the references to the dll's.

Is there a way round this problem? In C++ one could use header files... What
can I do here?
Nov 16 '05 #1
4 8234
pnp,
Use a Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Project1 would define UserControl1 along with Interface2. UserControl1 would
maintain a reference to Interface2. Interface2 would have any Properties,
Subs, Functions, or Events that UserControl1 needed of UserControl2.

Project2 would define UserControl2 which implements Interfac2.

Project2 would reference Project1, however Project1 would not reference
Project2.

Your form's project could reference both Project1 & Project2 & connect the
two controls on the forms.
However! I have to ask the question: Aren't you introducing too much
coupling if UserControl1 requires UserControl2 & visa versa? I would
seriously consider a Mediator Pattern instead of a Separated Interface
Pattern, as the Mediator would have a reference to the two controls
mediating any communication between the two controls. The form itself could
be the Mediator, or the Mediator could be its own UserControl or Component.

Hope this helps
Jay

"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:Os**************@TK2MSFTNGP09.phx.gbl...
I'm developing an app (in C #) that uses 2 usercontrols that must be in
different dll's.
The problem is that each one needs to use the other, so as a result I get a circular reference error when I try to add the references to the dll's.

Is there a way round this problem? In C++ one could use header files... What can I do here?

Nov 16 '05 #2
pnp
Thanks Jay, on your replying so soon.

By using interfaces the problem still remains because I need to create
objects of
classA in Proj1 in classB in Proj2 and vice versa... These are graphical
usercontrols and I don't want to put them in the same dll because they need
to be seperate modules... :(

Besides the mediator function, is there something else that could be done?
Peter N. P.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
pnp,
Use a Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Project1 would define UserControl1 along with Interface2. UserControl1 would maintain a reference to Interface2. Interface2 would have any Properties,
Subs, Functions, or Events that UserControl1 needed of UserControl2.

Project2 would define UserControl2 which implements Interfac2.

Project2 would reference Project1, however Project1 would not reference
Project2.

Your form's project could reference both Project1 & Project2 & connect the
two controls on the forms.
However! I have to ask the question: Aren't you introducing too much
coupling if UserControl1 requires UserControl2 & visa versa? I would
seriously consider a Mediator Pattern instead of a Separated Interface
Pattern, as the Mediator would have a reference to the two controls
mediating any communication between the two controls. The form itself could be the Mediator, or the Mediator could be its own UserControl or Component.
Hope this helps
Jay

"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:Os**************@TK2MSFTNGP09.phx.gbl...
I'm developing an app (in C #) that uses 2 usercontrols that must be in
different dll's.
The problem is that each one needs to use the other, so as a result I
get a
circular reference error when I try to add the references to the dll's.

Is there a way round this problem? In C++ one could use header files...

What
can I do here?


Nov 16 '05 #3
pnp,
No the problem does not still exist!

Are you saying you want to: create Control1 on top of Control2 on top of
Control1 on top of Control2 on infinity? that obviously wont work, or at
least it does not really make sense (to me) to visually nest one control on
another that is nested on itself.

What I gave will allow ClassA to have an instance of ClassB that also has a
reference to the first ClassA! Where ClassA & ClassB are in separate
projects.

Something like:

public interface Interface2
{
void Method2()
}

public class Class1
{

Interface2 i2;

public Class1(Interface2 i2)
{
this.i2 = i2;
}
}

public class Class2 : Interface2
{

Class1 c2;

public Class2()
{
c2 = new Class1(this);
}

void Method2()
{
}
}

Instead of passing is to expose a Interface2 property on UserControl1.
Depending on the requirements of the project I will actually use
Activator.CreateInstance to create an instance of the class that implements
the interface...

Because Project2 (class2) has a reference to Project1, Class2 can use
methods of Class1 directly. Class1 however uses methods of Class2 indirectly
via the interface. Note in this case the interface can be either an actual
Interface of a base Class.

Hope this helps
Jay
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:ea**************@TK2MSFTNGP12.phx.gbl...
Thanks Jay, on your replying so soon.

By using interfaces the problem still remains because I need to create
objects of
classA in Proj1 in classB in Proj2 and vice versa... These are graphical
usercontrols and I don't want to put them in the same dll because they need to be seperate modules... :(

Besides the mediator function, is there something else that could be done?
Peter N. P.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
pnp,
Use a Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Project1 would define UserControl1 along with Interface2. UserControl1

would
maintain a reference to Interface2. Interface2 would have any Properties, Subs, Functions, or Events that UserControl1 needed of UserControl2.

Project2 would define UserControl2 which implements Interfac2.

Project2 would reference Project1, however Project1 would not reference
Project2.

Your form's project could reference both Project1 & Project2 & connect the two controls on the forms.
However! I have to ask the question: Aren't you introducing too much
coupling if UserControl1 requires UserControl2 & visa versa? I would
seriously consider a Mediator Pattern instead of a Separated Interface
Pattern, as the Mediator would have a reference to the two controls
mediating any communication between the two controls. The form itself

could
be the Mediator, or the Mediator could be its own UserControl or

Component.

Hope this helps
Jay

"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:Os**************@TK2MSFTNGP09.phx.gbl...
I'm developing an app (in C #) that uses 2 usercontrols that must be in different dll's.
The problem is that each one needs to use the other, so as a result I get
a
circular reference error when I try to add the references to the dll's.
Is there a way round this problem? In C++ one could use header

files... What
can I do here?



Nov 16 '05 #4
pnp
Thanks a lot Jay. You helped me get out of a lot of trouble!

Peter

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
pnp,
No the problem does not still exist!

Are you saying you want to: create Control1 on top of Control2 on top of
Control1 on top of Control2 on infinity? that obviously wont work, or at
least it does not really make sense (to me) to visually nest one control on another that is nested on itself.

What I gave will allow ClassA to have an instance of ClassB that also has a reference to the first ClassA! Where ClassA & ClassB are in separate
projects.

Something like:

public interface Interface2
{
void Method2()
}

public class Class1
{

Interface2 i2;

public Class1(Interface2 i2)
{
this.i2 = i2;
}
}

public class Class2 : Interface2
{

Class1 c2;

public Class2()
{
c2 = new Class1(this);
}

void Method2()
{
}
}

Instead of passing is to expose a Interface2 property on UserControl1.
Depending on the requirements of the project I will actually use
Activator.CreateInstance to create an instance of the class that implements the interface...

Because Project2 (class2) has a reference to Project1, Class2 can use
methods of Class1 directly. Class1 however uses methods of Class2 indirectly via the interface. Note in this case the interface can be either an actual
Interface of a base Class.

Hope this helps
Jay
"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:ea**************@TK2MSFTNGP12.phx.gbl...
Thanks Jay, on your replying so soon.

By using interfaces the problem still remains because I need to create
objects of
classA in Proj1 in classB in Proj2 and vice versa... These are graphical
usercontrols and I don't want to put them in the same dll because they

need
to be seperate modules... :(

Besides the mediator function, is there something else that could be done?


Peter N. P.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
pnp,
Use a Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Project1 would define UserControl1 along with Interface2. UserControl1

would
maintain a reference to Interface2. Interface2 would have any Properties, Subs, Functions, or Events that UserControl1 needed of UserControl2.

Project2 would define UserControl2 which implements Interfac2.

Project2 would reference Project1, however Project1 would not reference Project2.

Your form's project could reference both Project1 & Project2 & connect the two controls on the forms.
However! I have to ask the question: Aren't you introducing too much
coupling if UserControl1 requires UserControl2 & visa versa? I would
seriously consider a Mediator Pattern instead of a Separated Interface
Pattern, as the Mediator would have a reference to the two controls
mediating any communication between the two controls. The form itself

could
be the Mediator, or the Mediator could be its own UserControl or

Component.

Hope this helps
Jay

"pnp" <pnp.at.softlab.ece.ntua.gr> wrote in message
news:Os**************@TK2MSFTNGP09.phx.gbl...
> I'm developing an app (in C #) that uses 2 usercontrols that must be in > different dll's.
> The problem is that each one needs to use the other, so as a result
I get
a
> circular reference error when I try to add the references to the

dll's. >
> Is there a way round this problem? In C++ one could use header files... What
> can I do here?
>
>



Nov 16 '05 #5

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

Similar topics

12
by: jinal jhaveri | last post by:
Hi All, I have one question regarding circular inheritance I have 3 files 1) A.py , having module A and some other modules 2) B.py having module B and some other modules 3) C.py having...
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: Jeff Connelly | last post by:
We're getting this error and don't know where to find the problem. I assume this is usually issued in the typical case where project A has a reference to project B, and project B has a reference...
3
by: Keith F. | last post by:
Visual Studio doesn't allow circular references between projects. I have a situation where I need to allow 2 projects to reference each other. Is there any way to make Visual Studio allow this? ...
0
by: Alan Samet | last post by:
Before telling me what I already know about what this error means, please read the post. I encountered this bizarre error when running aspnet_compiler.exe. Unfortunately, I don't know of a way...
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...
0
balabaster
by: balabaster | last post by:
Hi, I have a couple of tables: Units( Unit_PKey Int Identity(1,1) Primary Key, Unit_Name nvarchar(8), Unit_Description nvarchar(32) )
1
by: Marc Gravell | last post by:
The only common issue with circular object references is tree-based serialization (for example, XmlSerializer and DataContractSerializer in its default mode). Graph-based serializers...
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.