这是消除警告 C4945(符号已从另一个程序集导入)的正确方法吗?

发布于 2024-09-04 03:41:00 字数 311 浏览 5 评论 0原文

我有一个 .net 解决方案(用 C++/CLI 编写),它引用了一些 .dll 项目,如下所示:

MainProject->ProjectA->ProbjectB
MainProject->ProjectB

最初我引用了 MainProject 中的 ProjectA 和 ProjectB,这给了我如上所述的警告。

我可以通过从 ProjectMain 中删除对 ProjectB 的引用来删除警告,但这使得 MainProject 依赖于 ProjectB 变得不那么明显。这是消除警告的正确做法吗?

I've got a .net solution (written in C++/CLI) which references some .dll projects as follows:

MainProject->ProjectA->ProbjectB
MainProject->ProjectB

Originally I'd referenced both ProjectA and ProjectB from MainProject which gave me the warnings as mentioned above.

I can remove the warnings by removing the reference to ProjectB from ProjectMain but it makes it less obvious that MainProject relies on ProjectB. Is this the right thing to do to get rid of the warnings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

锦欢 2024-09-11 03:41:00

一般来说,依赖关系系统可以通过有向图来描述,其中每个节点都是一个软件组件,每条边都是一个依赖项。在我看来,图表越简化越好。

Speaking in general terms, a system of dependencies can be depicted by a directed graph where each node is a software component and each edge is a dependency. In my opinion, the more simplification that can be done to the graph, the better.

白鸥掠海 2024-09-11 03:41:00

是的,没关系。

如果您有 ReSharper,则可以通过右键单击 ProjectMain --> 查看依赖关系图。项目层次结构

Yeah that's fine.

If you have ReSharper, you can view the dependency graph by right-clicking ProjectMain --> Project Hierarchy.

酒中人 2024-09-11 03:41:00

我只想描述而不是解释以下相关行为。

  • C# 中的项目 CSCommon
  • C# 中的项目 CS1,使用 CSCommon
  • C++ 中的项目 CPP1,使用 CSCommon
  • 项目 CPPMain,使用 CPP1

如果每个项目都有自己的输出路径,我会收到 C4945。
如果所有项目都有共同的输出路径,警告就会消失。

I just want to describe, but not explain, following relevant behaviour.

  • project CSCommon in C#
  • project CS1 in C#, using CSCommon
  • project CPP1 in C++, using CSCommon
  • project CPPMain, using CPP1

If each project has its own output path, I recieve C4945.
If all projects have common outputh path, warning disappears.

只为一人 2024-09-11 03:41:00

我和你有同样的问题。我完全按照您的描述解决了这个问题:删除对“项目 B”的引用(在您的具体情况下)。
这是我知道如何修复此错误的唯一方法,除了禁用它之外。

I had the same problem as you. And I solved it exactly as you described it: remove the reference to 'Project B' (in your specific case).
That is the only way I know how to fix this error, short of disabling it.

情何以堪。 2024-09-11 03:41:00

不,删除引用可能不是处理它的正确方法。

请参阅https://stackoverflow.com/a/12423588/321013

设置在Build=false中使用依赖项供您参考。

关键是,您应该拥有项目本身中的代码用作直接引用的所有引用,但是设置 Use Dependencies in Build=TRUE 会干扰这一点,因为它还会引入传递引用,如果您也有直接引用,则会产生冲突。 (至少在我的VS2005上)

No, removing the reference is probably not the correct way to handle it.

See https://stackoverflow.com/a/12423588/321013

Set Use Dependencies in Build=false for your references.

The point is, that you should have all references that the code in the project itself uses as direct references, but the setting Use Dependencies in Build=TRUE interferes with that, as it pulls in the transitive references also, generating conflicts if you also have direct references. (At least on my VS2005)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文