Circular Reference Problem

G

Guest

Hi All,

I am here with a Query and need a Solution for it.

The Query is as Follows,

We have 3 Projects in a Solution - Say UI, CMN and PRD

First One Deals with UI Forms
Second One Deals with Common Functions that are needed for the Solution
And third One is for Product Specific Database Part.

Here the Last two are Class Library (Dlls) Projects which are Used in UI
Project.

And CMN Dll is Used in PRD Project too.

As of here, there is no Problem in Our Solution.

Now we are in a Need to Use PRD Dll in CMN which results in Circular
Reference Problem.

So We need a Solution to Avoid Circular Reference Problem Since as our
Product grew there may be Too Many Cross References.

Let me Know If any one have any Specific Solution for this Scenario.

Thanks In Advance
 
S

Simon Verona

I get round this problem by loading the dll using reflection at runtime ...
This gets round the requirement to add the reference, though you do lose
intellisense when programming as it's just an "object".

Hope this helps
Simon
 
C

Charles Law

I suspect that this is not what you want to hear, but I would look again at
why your CMN project requires access to your PRD project.

If you have a circular dependency then it suggests a flaw in your design. If
the CMN project contains common functions and classes, I would not expect it
to need specific access to the PRD project. If you have recently added a
class or function to CMN that references something in PRD, then perhaps you
should consider putting it in PRD.

HTH

Charles
 
S

Simon Verona

I don't know about the OP problem, but I have a similar problem which
whilst I could re-engineer with an extra dll that both projects refer to, I
have used reflection to get around the problem.

One example I have is as follows (just to show the validity) :

I have a "customer" object that contains a form that displays customer
history. Within customer history, I have sales history. To get a copy of a
sales invoice, I need to instantiate a salesinvoice object which has a "copy
invoice" function that I call from within the Customer history.

However, in order to get a copy of an invoice from within the sales history,
I need to create a customer object to get the customers name and address
details!

I could put the copy invoice function in another dll, but then this would
need access to the Salesinvoice and customer objects - I would still have a
circular reference... Or maybe I've just completely mis-designed my class
library layouts! (You've got me thinking now!)

Regards
 

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