Adding this project will cause a circular dependency

I have a two-build WPF application.

Build A is a wpf application.

Build B is an open-source 3D application mainly used by A.

Assembly A refers to assembly B.

Now that the event is fired on assembly B, I need to call the method in assembly A in the application of the static class.

If I try to add a reference to assembly A to B, I get an error:

Adding this project will cause a circular dependency

Do you have any ideas on how to solve it?

In particular, I would like to know:

  • How to call App.myMethod()in from assembly B?
  • To separate classes, can I fire a common event on assembly B and catch it on assembly A?
  • Any other ideas are welcome.
+4
3

App.myMethod B?

, A B.

- B, A:

A:

var classB = new ClassB();  // presumably in your code in A somewhere
classB.MyEvent += new EventHandler(this.HandleEventFromB);


public void HandleEventFromB(object sneder, EventArgs args)
{
    ClassA.StaticMethod();
}

, B A.

, "" B - , A.

+7

, DLL, .

+2

. , /.

When an event fires in B, I assume that it creates some data. If you can store this data in a database or similarly, then maybe this is a time event in Appendix A, which essentially listens for this data, and then provides for updating it if necessary.

0
source

Source: https://habr.com/ru/post/1529825/


All Articles