开发者

Is this the correct way to eliminate warning C4945 (symbol already imported from another assembly)?

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

Main开发者_JAVA百科Project->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?


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.


Yeah that's fine.

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


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.


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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜