how resolve this circular reference issue?

  • Thread starter Thread starter ChrisB
  • Start date Start date
C

ChrisB

Hello,

I was wondering what options are available for resolving the following
(simplified) scenario.

Two project exist and each contains a class:
ProjectA - Class1
ProjectB - Class2

Additionally, Class2 needs to accept Class1 as a parameter:
public class Class2
{
// results in circular reference
public static void CompleteAction(Class1 Class1)
}

Because Class1 needs a reference to ProjectB to access the Class2 static
method, and Class2 needs a reference to ProjectA because of the Class1
parameter, a circular reference is created. Is there any way to resolve
this issue short of combining classes 1 and 2 in the same assembly?

Thanks,
Chris
 
Because Class1 needs a reference to ProjectB to access the Class2 static
method, and Class2 needs a reference to ProjectA because of the Class1
parameter, a circular reference is created. Is there any way to resolve
this issue short of combining classes 1 and 2 in the same assembly?

Add an interface IClass1 in a third assembly. reference it from both
projects. Implement it in Class1 and change the parameter type of
CompleteAction to IClass1.


Mattias
 
Thanks for the suggestion. Sounds like this may be the way to go.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top