469,644 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

strong reference between objects in different assemblies

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
May 1 '06 #1
6 1050
You could use an interface.

Craig Buchanan wrote:
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

May 1 '06 #2
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%******************@TK2MSFTNGP05.phx.gbl...
You could use an interface.

Craig Buchanan wrote:
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

May 1 '06 #3
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.

Craig Buchanan wrote:
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%******************@TK2MSFTNGP05.phx.gbl...
You could use an interface.

Craig Buchanan wrote:
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


May 3 '06 #4
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?

"Göran Andersson" <gu***@guffa.com> wrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
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.

Craig Buchanan wrote:
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%******************@TK2MSFTNGP05.phx.gbl...
You could use an interface.

Craig Buchanan wrote:
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


May 3 '06 #5
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.

Craig Buchanan wrote:
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?

"Göran Andersson" <gu***@guffa.com> wrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
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.

Craig Buchanan wrote:
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%******************@TK2MSFTNGP05.phx.gbl...
You could use an interface.

Craig Buchanan wrote:
> 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

May 3 '06 #6
Thanks, I will give this approach a try.

"Göran Andersson" <gu***@guffa.com> wrote in message
news:eS**************@TK2MSFTNGP05.phx.gbl...
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.

Craig Buchanan wrote:
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?

"Göran Andersson" <gu***@guffa.com> wrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
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.

Craig Buchanan wrote:
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%******************@TK2MSFTNGP05.phx.gbl...
> You could use an interface.
>
> Craig Buchanan wrote:
>> 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

May 4 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Ted | last post: by
4 posts views Thread by Derrick | last post: by
10 posts views Thread by Tony Jones | last post: by
2 posts views Thread by Thomas W. Brown | last post: by
7 posts views Thread by Alan T | last post: by
6 posts views Thread by raylopez99 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.