strong reference between objects in different assemblies

  • Thread starter Thread starter Craig Buchanan
  • Start date Start date
C

Craig Buchanan

i have two classes: User and Group. Each is in their own assembly. The
User class has Groups collection and the Group has a Users collection. I
would like to strongly-type these collections, but i can't seem to avoid the
circular reference between projects. is there a way around this?

Thanks,

Craig Buchanan
 
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).
 
No, you only need an interface for one class. Then the other class can
use the interface for handling objects of the first class, and doesn't
even need to know that the first class exists.
 
If I keep the interface in the same assembly as the class, i haven't solved
the problem. for example:

MyFramework.Plugins.UserPlugin assembly contains:
User class
IUser interface

MyFramework.Plugins.GroupPlugin assembly contains:
Group class
IGroup interface

The GroupPlugin assembly can have a reference to the UserPlugin or
UserPlugin assembly can have a reference to the GroupPlugin, but not both at
the same time.

My goal is to create a plugin framework, where a given framework can have a
strong reference to a class in another plugin assembly. i want to have the
option to have interdependencies as well (as above).

I may have to have both of these classes in one assembly.

thoughts?
 
Put the interface for the class in the other assembly:

1:
IUser interface
Group class

2:
User class implements IUser

Assembly 2 references assembly 1. The Group class uses IUser to
reference user objects, and the User class can use Group objects.

Or the other way around if you like. Or you can put interfaces for both
classes in one of the assemblies. Or but the interfaces in a separate
assembly.
 
Thanks, I will give this approach a try.

Göran Andersson said:
Put the interface for the class in the other assembly:

1:
IUser interface
Group class

2:
User class implements IUser

Assembly 2 references assembly 1. The Group class uses IUser to reference
user objects, and the User class can use Group objects.

Or the other way around if you like. Or you can put interfaces for both
classes in one of the assemblies. Or but the interfaces in a separate
assembly.
 
Back
Top