circular dependence

G

Guest

I have 2 dlls and they reference each other, thus causing the circular
dependence error. I have read about other cases and people say use
Interfaces to solve the problem with the shared methods. My case is getting
the error, not because methods need shared, but because forms need shared.
Example:
A.DLL has form TestA1, TestA2
B.DLL has form TestB

TestA1 navigates to display TestB, thus A.DLL needs to reference B.DLL so
the form will show. TestB navigates to display TestA2, thus B.DLL needs to
reference A.DLL so the form will show.

Will using an interface help in this situation? It doesn't seem that is
will but I might be missing something. Also, I want to keep the dlls
separate because they represent two different sets of business.
 
J

John M Deal

Yes, however it doesn't seem like you need to define your own additional
interface, you just need to use the Form base class that both DLLs
reference. To do this you can create either a constructor or a public
property on TestB that accepts a form reference. Then when you build
TestB (but before you display it) you set the property (or constructor
parameter) to an instance of TestA2. Then when you normally finish up
with TestB and display TestA2 you simply display whatever form was
passed into TestB.

You could extend this to a proprietary interface in a third DLL but it
really wouldn't change things much (other than to make sure any extra
properties that you might need to set from TestA and TestB are available
to each.

Have A Better One!

John M Deal, MCP
Necessity Software
 

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