I have a WPF application composed by two assemblies.
Assembly A is a wpf application.
Assembly B is a 3D app whit a public API mainly used by A.
Assembly A has a reference to assembly B.
Now when an event fires on assembly B I need to call a method in assembly A in a static class app.
If I try to add a reference to assembly A in B I get an error:
adding this project will cause a circular dependency
Do you have any ideas on how to solve it?
Specifically I would like to know:
App.myMethod()
in A from assembly B
?How do I call
App.myMethod
in A from assembly B?
You can't if A depends on B.
If the event is fired from some class in B you should subscribe to that event from some class in A:
code in 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();
}
That way B is not dependent on A.
You may need to "bubble up" the event within B to some publicly exposed event in order to subscribe to it from A.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With