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

How can i solve if i have the circular dependence?

Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i
add the dll in the reference. However, once i add for one of the namespace,
then i cannot add to another. Thwn what should i do to sovle this case of
problem ??

Best wishes,
Micmic
Nov 15 '05 #1
12 1345
micmic <bi**********@hotmail.com> wrote:
Dear all experts,
I have the Coding as following:
<snip>
where abc and bcd is in different project files. In order to make it work, i
add the dll in the reference. However, once i add for one of the namespace,
then i cannot add to another. Thwn what should i do to sovle this case of
problem ??


You can't have two projects which depend upon each other. What you
*can* have, is an interface that one of the types implements, have that
in a third project which both projects depend on, and get out that way.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
In article <em*************@TK2MSFTNGP12.phx.gbl>, bigmouth1979
@hotmail.com says...
Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i
add the dll in the reference. However, once i add for one of the namespace,
then i cannot add to another. Thwn what should i do to sovle this case of
problem ??

Best wishes,
Micmic

I had this problem, and short of putting all code in the same project
you need to do a bit of thinking about how to organize your projects. It
actually can help in showing if you have two many dependencies.

--
Thanks
Mark mm
Nov 15 '05 #3
Actually i don't mind by puting them in one project. But i would like to ask
whether you have different namespaces. ( But will it be too mess up if you
put into the same project?)

"Mark mm" <ma********@hotmail.com> ???
news:MP************************@News.CIS.DFN.DE ???...
In article <em*************@TK2MSFTNGP12.phx.gbl>, bigmouth1979
@hotmail.com says...
Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i add the dll in the reference. However, once i add for one of the namespace, then i cannot add to another. Thwn what should i do to sovle this case of problem ??

Best wishes,
Micmic

I had this problem, and short of putting all code in the same project
you need to do a bit of thinking about how to organize your projects. It
actually can help in showing if you have two many dependencies.

--
Thanks
Mark mm

Nov 15 '05 #4
micmic <bi**********@hotmail.com> wrote:
Actually i don't mind by puting them in one project. But i would like to ask
whether you have different namespaces. ( But will it be too mess up if you
put into the same project?)


Namespaces and assemblies as entirely separate concepts. You can have
multiple namespaces in an assembly, or (more rarely) namespaces which
have members spread across multiple assemblies.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5

As I recall for Java Interface, it will code the implement Class which
implement the Interface. But if I just wanna assign the value to which Class
is passed in 1 project . ie.

namespace A
{
public class abc
{
private int value1;
......................

public abc()
{
B.bcd xxx = new B.bcd(this);

}
public int Value1
{
get{return value1;}
set {value1=value;}

}
..................................

}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
xxx.Value1=uuu;
xxx.Value2=vvv;
xxx.Value3=www;
xxx.Value4=yyy;
}
}

}

I still can use the method you said ??

Best wishes,
Michael

"Jon Skeet [C# MVP]" <sk***@pobox.com> ???
news:MP************************@msnews.microsoft.c om ???...
micmic <bi**********@hotmail.com> wrote:
Dear all experts,
I have the Coding as following:


<snip>
where abc and bcd is in different project files. In order to make it work, i add the dll in the reference. However, once i add for one of the namespace, then i cannot add to another. Thwn what should i do to sovle this case of problem ??


You can't have two projects which depend upon each other. What you
*can* have, is an interface that one of the types implements, have that
in a third project which both projects depend on, and get out that way.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #6
micmic <bi**********@hotmail.com> wrote:

<snip>
I still can use the method you said ??


No. You just can't have two assemblies which require references to each
other.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #7

Hi, micmic!
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i add the dll in the reference. However, once i add for one of the namespace, then i cannot add to another. Thwn what should i do to sovle this case of
problem ??


Your must create third class library and declare abstract class abc_base:

Lib 3:

namespace A
{
public abstract class abc_base
{
...
}
}

then Lib 1 must references to Lib2 and Lib3

namespace A
{
public class abc: abc_base
{
...
}
}

and Lib 2 reference to Lib3

using A;
namespace B
{
public class bcd
{
public bcd(A.abc_base qqq)
{
...
}
}
}

Sorry for bad english.
--
Roman S. Golubin
ICQ UIN 63253392
go*****************@arhcity.ru
Nov 15 '05 #8
Micmic,
In addition to the other's comments.

It sounds like you need to use the Separated Interface Pattern.

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

In bcd.cs define interface Iabc, which has the methods that bcd needs to use
from abc. The constructor to bcd accepts an Iabc interface. The A project
would reference the B project, while the B project does not reference the A
project.

Something like:
In File abc.cs
namespace A
{
public class abc : Iabc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

} void method1()
{
} }

}

in file bcd.cs
namespace B
{ public interface iabc
{
void method1();
} public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}
Hope this helps
Jay

"micmic" <bi**********@hotmail.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl... Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i add the dll in the reference. However, once i add for one of the namespace, then i cannot add to another. Thwn what should i do to sovle this case of
problem ??

Best wishes,
Micmic

Nov 15 '05 #9
but in the bcd.cs, i would like to assign the value for abc class

namespace A
{
public class abc
{
private int value1;
......................

public abc()
{
B.bcd xxx = new B.bcd(this);

}
public int Value1
{
get{return value1;}
set {value1=value;}

}
..................................

}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
xxx.Value1=uuu;
xxx.Value2=vvv;
xxx.Value3=www;
xxx.Value4=yyy;
}
}

}

Can I use the method you mention ?

Best wishes,
Micmic
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> ¦b¶l¥ó
news:%2***************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
Micmic,
In addition to the other's comments.

It sounds like you need to use the Separated Interface Pattern.

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

In bcd.cs define interface Iabc, which has the methods that bcd needs to use from abc. The constructor to bcd accepts an Iabc interface. The A project
would reference the B project, while the B project does not reference the A project.

Something like:
In File abc.cs
namespace A
{
public class abc : Iabc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

} void method1()
{
}
}

}

in file bcd.cs
namespace B
{

public interface iabc
{
void method1();
}
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}


Hope this helps
Jay

"micmic" <bi**********@hotmail.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl...
Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it work, i
add the dll in the reference. However, once i add for one of the

namespace,
then i cannot add to another. Thwn what should i do to sovle this case

of problem ??

Best wishes,
Micmic


Nov 15 '05 #10

Hi, Jay B. Harlow!

then correct bcd constructor:

in file bcd.cs
namespace B
{

public interface iabc
{
void method1();
}
public class bcd
{
...................
public bcd (iabc xxx)
public bcd (abc xxx)
{
.............................
}
}

}

--
Roman S. Golubin
ICQ UIN 63253392
go*****************@arhcity.ru
Nov 15 '05 #11
Roman,
Doh! it was a quick example ;-)

Jay

"Roman S. Golubin" <go*****************@arhcity.ru> wrote in message
news:bv**********@arhadm.atnet.ru...

Hi, Jay B. Harlow!

then correct bcd constructor:

in file bcd.cs
namespace B
{

public interface iabc
{
void method1();
}
public class bcd
{
...................
public bcd (iabc xxx)
public bcd (abc xxx)
{
.............................
}
}

}

--
Roman S. Golubin
ICQ UIN 63253392
go*****************@arhcity.ru

Nov 15 '05 #12
micmic,
but in the bcd.cs, i would like to assign the value for abc class The Iabc interface needs to define everything that bcd needs from abc. It is
the "third party" contract between abc & bcd.

So you need to have properties for Value1, Value2, Value3, and Value4
defined in the IAbc interface, that bcd can use that abc itself can
implement.

Iabc is the Separated Interface. Note Separated Interface could be
implemented with a base class (abstract or otherwise) instead of an actual
interface.
namespace A
public class abc : Iabc
{
namespace B
interface Iabc
{
int Value1 { get; set; }
int Value2 { get; set; }
int Value3 { get; set; }
int Value4 { get; set; }
int Value5 { get; set; }
}
public class bcd
{
...................
public bcd (Iabc xxx)
{
.............................
xxx.Value1=uuu;
xxx.Value2=vvv;
xxx.Value3=www;
xxx.Value4=yyy;
}
}
Hope this helps
Jay

"micmic" <bi**********@hotmail.com> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl... but in the bcd.cs, i would like to assign the value for abc class

namespace A
{
public class abc
{
private int value1;
......................

public abc()
{
B.bcd xxx = new B.bcd(this);

}
public int Value1
{
get{return value1;}
set {value1=value;}

}
..................................

}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
xxx.Value1=uuu;
xxx.Value2=vvv;
xxx.Value3=www;
xxx.Value4=yyy;
}
}

}

Can I use the method you mention ?

Best wishes,
Micmic
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> ¦b¶l¥ó
news:%2***************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
Micmic,
In addition to the other's comments.

It sounds like you need to use the Separated Interface Pattern.

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

In bcd.cs define interface Iabc, which has the methods that bcd needs to use
from abc. The constructor to bcd accepts an Iabc interface. The A project
would reference the B project, while the B project does not reference

the A
project.

Something like:
In File abc.cs
namespace A
{
public class abc : Iabc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}

void method1()
{
}
}

}

in file bcd.cs
namespace B
{

public interface iabc
{
void method1();
}
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}


Hope this helps
Jay

"micmic" <bi**********@hotmail.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl...
Dear all experts,
I have the Coding as following:
In File abc.cs
namespace A
{
public class abc
{

public abc()
{
B.bcd xxx = new B.bcd(this);

}
}

}

in file bcd.cs
namespace B
{
public class bcd
{
...................
public bcd (abc xxx)
{
.............................
}
}

}

where abc and bcd is in different project files. In order to make it

work,
i
add the dll in the reference. However, once i add for one of the

namespace,
then i cannot add to another. Thwn what should i do to sovle this case

of problem ??

Best wishes,
Micmic



Nov 15 '05 #13

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

Similar topics

1
by: Henry Miller | last post by:
I have the following code (much simplified for this post). Note that SessionKey uses DataAccess, and DataAccess requires SessionKey in it's constructor. Public Class SessionKey Public...
2
by: ernesto basc?n pantoja | last post by:
Hi everybody: I'm implementing a general C++ framework and I have a basic question about circular dependencies: I am creating a base class Object, my Object class has a method defined as:...
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...
4
by: Henke | last post by:
I have this scenario. public class A { public int numbers; public class A() { }
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...
11
by: Kenneth Lantrip | last post by:
Anyone got any ideas as to how this process could be improved for speed? this is what I have... Dim j, q As Integer Dim x(16), y(16) As Byte x.CopyTo(y, 0) ' shift left circular 24 bits
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)...
7
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time...
3
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I Have a solution with about 50 projects and each project have References to 1 to n of the projects in the solution. I try go to a project and try to add a reference to another project and 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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.