Problem in adding circular references

G

Gos

Hi,

It is known that .NET does not allow us to add circular references. Is
there a way to workaround this problem by late-binding the objects at
run time? Will this create any other problems?

One solution to the problem is to re-architect the solution. But, I
dont want to do this as there are many modules in the project which
are already developed and nearing the release.

Any help would be appreciated.

Thanks
Gos
 
S

steve

late binding creates performance and maintanence problems...and still holds
a reference to whatever you are trying to reference circularly. .net will
handle the reference just as it would in early binding.

i can't remember the exact example i saw here of creating/managing circular
references...either someone will post it again or advise you otherwise.

hth,

steve
 
J

Jay B. Harlow [MVP - Outlook]

Gos,
..NET fully supports circular references between objects!

Are you referring to circular references between projects?

What I would suggest is a Separated Interface Pattern.
http://www.martinfowler.com/eaaCatalog/separatedInterface.html

When you implement this pattern you can dynamically load one of the classes
if you want giving you the a benefit of late-binding. However! because of
the Separated Interface you will have the benefit of early binding also.

If you search the microsoft.public.dotnet.* newsgroups at groups.google.com
for Separated Interface Pattern you should find a number of references and
other tidbits on the above pattern.

Hope this helps
Jay
 
A

Armin Zingler

Gos said:
It is known that .NET does not allow us to add circular references.

I'm almost sure that this is not true. In opposite to earlier times using
circular references with COM objects, the garbage collector does recognize
and collect "lost" objects that are no longer referenced anymore.
 
G

Gos

I am talking about circular reference between projects. I am sorry if
I haven't made it clear. I know that .NET supports circular reference
with objects but not projects. I am also not sure whether I will be
able to have interfaces in my program because it is a service based
architecture and the forms are 'Friend' members of a DLL. I have to
access the outside world through my service class. It is something
like MainForm->ServiceClasses(DLL entry point)->Classes &
Forms(contained in DLL).

Project A(serviceclass) has reference to Project B(serviceclass)
already. I want access to Project A from Project B now. I am trying to
create a new object of type 'System.Object' and assign an instance of
A to this object in MainForm and pass the new object to Project B
(instead of passing a type which is of Type A, I am passing an
'System.Object' type to B and call the method in A through that object
using late-binding.) But, I haven't yet tested it. Please let me know
if you have any other suggestions. I will post my solution if it
works.

Thanks
 
G

Gos

I have got rid that problem by event handling mechanism. Though it is
not a very good solution, the team does not want to re-architect the
project.

Thanks for your help.

Gos
 

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

Top