C#-循环引用,看不到命名空间 [英] C# - Circular Reference and cannot see Namespace

查看:78
本文介绍了C#-循环引用,看不到命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个项目的解决方案.

I have a solution with 2 projects.

Raven是一个简单的基础,可为第二个项目PPather提供数据,以供处理.第二个项目依赖于第一个项目进行编译,因此要构建它,我添加了对Raven的引用.到目前为止一切正常.

One, Raven, is a simple base that provides data for the second project, PPather, to do stuff with. The second project depends on the first to compile so to build it, I add a reference to Raven. All works well so far.

现在,我希望Raven启动PPather.但是它看不到PPather naemspace,所以我看不到.解决该问题的所有努力都会导致循环引用错误.

Now I want Raven to launch PPather. But it can't see the PPather naemspace so I can't. All efforts to resolve this lead to circular reference errors.

任何人都知道如何让Raven看到依赖于它的PPather项目的名称空间吗?

Anyone know how I can get Raven to see the namespace of the PPather project that depends on it?

推荐答案

您不能-无法像您想的那样以循环方式引用程序集.如果需要创建循环引用,很可能没有正确设计这些程序集.

You can't - there is no way to reference assemblies in a circular manner like you want to do. Most likely you have not properly designed these assemblies if you need to create a circular reference.

您的第一个程序集是一个依赖项,因此其中除了 its 依赖项之外,不应该有任何其他知道任何其他代码的代码.一旦您的程序集变得智能"并开始了解其自己的依存关系之外的任何内容,您将开始面临严重的维护和可伸缩性难题.我将考虑以不需要创建循环引用的方式来重新组织代码.

Your first assembly is a dependency so there should not be any code in there that knows about anything other than its dependencies. Once your assemblies become "smart" and begin to have knowledge of anything outside their own dependencies you will begin to have serious maintenance and scalability headaches. I would look into reorganizing your code in such a manner that you do not need to create the circular reference.

这篇关于C#-循环引用,看不到命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆