Re: circular dependence

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: John M Deal (johndeal_at_necessitysoftware.com)
Date: 11/22/04


Date: Sun, 21 Nov 2004 20:13:24 -0800

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

Leslie wrote:
> 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.



Relevant Pages

  • Re: VB6 - questions about references
    ... Remember when adding a 'reference' you are essentially adding a reference ... for a particular com interface, and not just including any particular ... Some dlls actually include several interfaces, ...
    (microsoft.public.vb.general.discussion)
  • Re: circular references
    ... class A from dll_a depending on class B from dll_b and class B from dll_b ... >> Do you mean 2 class libraries (dlls)? ... >> two original ones reference that. ... >> can be just an interface and not the actual implementation. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: 7.0 wishlist?
    ... The "auto-implement" is intended mainly for the odd situation where an existing class you can't edit fits some interface and you're willing to take responsibility for it if it turns out not to actually adhere to the contract, and try using it where that interface type is expected. ... If reference declarations started showing up with the odd asterisk, bang, or other punctuation mark on it, but never primitive declarations, people would probably be able to guess what was going on, on the basis of "what other binary flag might be set on references but not primitives and would be really useful besides can be/cannot be null?" ... the compiler cannot prove by static analysis that the RHS isn't null might be a good idea. ... Object foo, bar; ...
    (comp.lang.java.programmer)
  • Re: Anders Hejlsberg comment on immutable objects
    ... >explicit interface implementation exists is so an interface name can class ... Improper implicit conversions constitute a nasty ... >> With value types, the variable's value is the object, not a reference ... Consider the affects of our different views on a const ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: please try this program (generic resolution)
    ... of the specific interfaces of a generic interface that has that name and ... either is in the scoping unit in which the reference appears or is made ... And now in my example I misspelled ENISOC. ... external fun ...
    (comp.lang.fortran)