Are cross references possible?

curiouswebster
curiouswebster used Ask the Experts™
on
Back when I wrote C++, there was no way to have references to objects which also referenced the original object. But is this stil true in C#?

I am, for the first time, breaking up my main project into various namespaces and projects, for a variety of reasons. But I am having trouble when certain objects reference many other object types.

Can anny C# progject contain a reference to any other C# project? Or wouldn't this create a circular reference?

Curious.

newbieweb
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
The short answer is 'no'. Two projects can't reference each other. Visual Studio does not allow this if someone tries to set such a dependency.
This is still the same as in c++

Circular references are not allowed by the IDE (however if absolutely necessary - I can't see why at this point. You can use reflection to complete your reference)

This is not advisable and there is always a way to redesign your object model so that this never occurs.
anarki_jimbelSenior Developer
Commented:
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

curiouswebsterSoftware Engineer

Author

Commented:
I don't want to use circular dependencies, but I have a problem. I started building this Windows WinForms program years ago, as my first C# program, after years of C++. The concept of namespace was new and I did not adopt it. And as the sole programmer, it didn't much matter. But the application has grown over many years, and still uses one single namespace. So I have to give any developer the whole source code base, and that's kept me shy about having subcontractors help me.

I am trying to break the probecyt up but it seems like it will be a complex task. I create an object called Handles, and made is a centtral object throughout the program. Almost every object used Handles since it's a catch all for references to every important object in the program. Also, that's where the exception handleer code originates, which is another reason for the Handles object being referenced by practially everything.

So I'm in a pickle. Any suggestions?

Is there a common object, like ASP.NET, where I can store my own object types? That might help me untangle some of the intermarriages of many of these objects, but for the type to be addressable is still another issue.

I'm really in an pickle since I'm try9ing to get stated with what will be a new version. But given I have a very short time to finish it, must start with the earlier version as a starting point.

Please let me hear your opinions.

Thanks,
newbieweb
anarki_jimbelSenior Developer
Commented:
I can't see any problems with your "Handles" object. I'd move it to a separate project (namespace) and all other projects may use it. But "Handles" project shouldn't refer any other projects, of course. Is that possible in your solution? If yes - this Handles won't create any circular reference.
curiouswebsterSoftware Engineer

Author

Commented:
I think I need to rewrite this whole thing. But later.

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial