Jon Cage
Jon Cage

Reputation: 37518

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:

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?

Upvotes: 3

Views: 4802

Answers (5)

Martin Ba
Martin Ba

Reputation: 38941

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)

Upvotes: 0

filip.r
filip.r

Reputation: 31

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.

Upvotes: 1

C.J.
C.J.

Reputation: 16111

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.

Upvotes: 0

Reinderien
Reinderien

Reputation: 15283

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.

Upvotes: 2

Yeah that's fine.

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

Upvotes: 2

Related Questions