如果我有循环依赖,我该如何解决? [英] How can i solve if i have the circular dependence?
问题描述
亲爱的所有专家,
我有以下编码:
文件abc.cs
名称空间A
{
公共等级abc
{
public abc()
{
B.bcd xxx = new B.bcd(this);
}
}
}
文件bcd.cs中的
名称空间B
{
public class bcd
{
...................
public bcd(abc xxx)
{
............................. />
}
}
}
其中abc和bcd在不同的项目文件中。为了使其工作,我将在参考中添加dll
。但是,一旦我添加了一个命名空间,
然后我就无法添加到另一个。我应该怎么做才能解决这个问题?
问题??
祝你好运,
Micmic
micmic< bi ********** @ hotmail.com>写道:亲爱的所有专家,
我有以下编码:
< snip>
其中abc和bcd在不同的项目文件中。为了使其工作,我在参考中添加了dll。但是,一旦我添加了一个命名空间,
然后我就无法添加到另一个。我该怎么办才能解决这个问题呢?
你不可能有两个相互依赖的项目。你可以*拥有的是一个类型实现的接口,在两个项目所依赖的第三个项目中拥有那个
,然后以这种方式离开。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复该群组,请不要给我发邮件
在文章< em ************* @ TK2MSFTNGP12.phx.gbl>中,bigmouth1979
@ hotmail.com说...亲爱的所有专家,
我的编码如下:
在文件中abc.cs
命名空间A
{
公共课abc
公共abc()
{
B.bcd xxx = new B.bcd(这个);
}
文件bcd.cs
命名空间B
{
公共课bcd
{
...................
public bcd(abc xxx)
{
........... ..................
}
}
其中abc和bcd是在不同的项目文件中。为了使其工作,我在参考中添加了dll。但是,一旦我添加了一个命名空间,
然后我就无法添加到另一个。我该怎么做才能解决这个问题呢?
祝你好运,
Micmic
我有这个问题,并没有将所有代码放在同一个项目中
你需要考虑如何组织你的项目。它实际上可以帮助显示你是否有两个依赖项。
-
谢谢
Mark mm
其实我不介意将它们放在一个项目中。但我想询问
你是否有不同的命名空间。 (但是如果你把
投入同一个项目会不会太乱?)
" Mark mm" <毫安******** @ hotmail.com> ????
新闻:MP ************************ @ News.CIS.DFN.DE ??? ..在文章< em ************* @ TK2MSFTNGP12.phx.gbl>中,bigmouth1979
@ hotmail.com说... < blockquote class =post_quotes>亲爱的所有专家,
我的编码如下:
在文件中abc.cs
命名空间A
{
public class abc <公共abc()
{
B.bcd xxx = new B.bcd(this);
}
}
文件bcd.cs
名称空间B
{
公共类bcd
{
...................
public bcd(abc xxx)
{
........... ..................
}
}
其中abc和bcd是在不同的项目文件中。为了使
工作,我在参考中添加了dll。但是,一旦我为
命名空间中的一个添加,我就无法添加到另一个。我应该怎样做才能解决这个案子
的问题?
祝你好运,
Micmic
我有这个问题,并且没有将所有代码放在同一个项目中
你需要考虑如何组织你的项目。它实际上可以帮助显示你是否有两个依赖项。
-
谢谢
Mark mm
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
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
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
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
这篇关于如果我有循环依赖,我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!