Groups | Blog | Home
all groups > dotnet general > november 2006 >

dotnet general : how resolve this circular reference issue?


ChrisB
11/9/2006 10:10:58 PM
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

Mattias Sjögren
11/10/2006 12:00:00 AM
[quoted text, click to view]

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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
ChrisB
11/10/2006 11:31:44 AM
Thanks for the suggestion. Sounds like this may be the way to go.

Chris

[quoted text, click to view]

AddThis Social Bookmark Button