这是消除警告 C4945(符号已从另一个程序集导入)的正确方法吗?
我有一个 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
一般来说,依赖关系系统可以通过有向图来描述,其中每个节点都是一个软件组件,每条边都是一个依赖项。在我看来,图表越简化越好。
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.
是的,没关系。
如果您有 ReSharper,则可以通过右键单击 ProjectMain --> 查看依赖关系图。项目层次结构。
Yeah that's fine.
If you have ReSharper, you can view the dependency graph by right-clicking ProjectMain --> Project Hierarchy.
我只想描述而不是解释以下相关行为。
如果每个项目都有自己的输出路径,我会收到 C4945。
如果所有项目都有共同的输出路径,警告就会消失。
I just want to describe, but not explain, following relevant behaviour.
If each project has its own output path, I recieve C4945.
If all projects have common outputh path, warning disappears.
我和你有同样的问题。我完全按照您的描述解决了这个问题:删除对“项目 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.
不,删除引用可能不是处理它的正确方法。
请参阅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)