2

We have a solution with a number of projects.

In one particular case, we have two projects: 1) A C# project that does most of the work 2) A C++/CLI project that acts as a go-between to some native C++ code

The C# code calls into the C++ wrapper, all is well.

However, there is some new functionality that we are pulling in. On the managed side of the C++ wrapper (project #2), it requires some static methods in the managed C# code that is in project #1. However, Visual Studio will not let us mutually associate these two projects as it complains of a circular project reference. There is no circular class reference however.

Is there any solution to this problem that does not require a 3rd project as an intermediary?

Joe
  • 41,484
  • 20
  • 104
  • 125
  • Compile a dll (or more than one dll) for your new functions... Its cheating in that its it basically creating an intermediary, but its not a project. – soandos May 12 '11 at 19:24
  • Yeah, forgot to mention, we more or less don't allow binary references for our internal stuff, so it has to be a project reference in one way or another. – Joe May 12 '11 at 19:27

1 Answers1

5

You can have A depend on B. For simplicity lets say A.EXE depends on B.DLL. Then when A initially calls B, it can give it an object of some type or interface that is defined in B and then B can turn around and call back into A at some later point.

In other words, B defines a base class or interface like "I want something that only A can do" but don't implement it. Then let A implements it, passes it to you, and calls it. This gets around the circular dependency without a third project. This applies to any pair of managed projects.

Rick Sladkey
  • 33,988
  • 6
  • 71
  • 95