Circular References...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    Circular References...

    Let's assume I have the following libraries:

    MainLib (DLL)
    MyControl (.NET user control)

    Now MyControl needs to call MainLib, so I have a reference to MainLib
    in MyControl. Let's then assume that I want to put a new form
    (MyNewForm) in MainLib, but this form requires MyControl (i.e. I will
    drop a copy if MyControl onto the MyNewForm). This would require me to
    put a reference to MyControl in MainLib. Now I have MainLib referencing
    MyControl, and MyControl referencing Mainlib!

    Would this kind of circular reference even work? My problem is in what
    order would something like this be compiled? I would think I would
    first have to compile MyControl, then MainLib; but as soon as I
    recompile MainLib the reference to MainLib in MyControl is now not
    'current'...

    Ugh, it hurts my head just thinking about this... I suppose the better
    way would just be to make MyNewForm into it's own DLL, but was
    wondering if something like the above scenario would work or is it even
    recommended?

    Thanks.

    Tom
  • Brian Gideon

    #2
    Re: Circular References...

    Tom,

    It is definitely not recommended. You should put MyNewForm into
    another assembly or in the same assembly that contains MyControl.

    Brian

    Tom wrote:[color=blue]
    > Let's assume I have the following libraries:
    >
    > MainLib (DLL)
    > MyControl (.NET user control)
    >
    > Now MyControl needs to call MainLib, so I have a reference to MainLib
    > in MyControl. Let's then assume that I want to put a new form
    > (MyNewForm) in MainLib, but this form requires MyControl (i.e. I will
    > drop a copy if MyControl onto the MyNewForm). This would require me to
    > put a reference to MyControl in MainLib. Now I have MainLib referencing
    > MyControl, and MyControl referencing Mainlib!
    >
    > Would this kind of circular reference even work? My problem is in what
    > order would something like this be compiled? I would think I would
    > first have to compile MyControl, then MainLib; but as soon as I
    > recompile MainLib the reference to MainLib in MyControl is now not
    > 'current'...
    >
    > Ugh, it hurts my head just thinking about this... I suppose the better
    > way would just be to make MyNewForm into it's own DLL, but was
    > wondering if something like the above scenario would work or is it even
    > recommended?
    >
    > Thanks.
    >
    > Tom[/color]

    Comment

    • Phill.  W

      #3
      Re: Circular References...

      "Tom" <tom@nospam.com > wrote in message
      news:uWhJYw0eFH A.2244@TK2MSFTN GP15.phx.gbl...[color=blue]
      > MyControl needs to call MainLib, so I have a reference to MainLib
      > in MyControl. Let's then assume that I want to put a new form
      > (MyNewForm) in MainLib, but this form requires MyControl
      > (i.e. I will drop a copy if MyControl onto the MyNewForm).
      > This would require me to put a reference to MyControl in MainLib.[/color]
      .. . .[color=blue]
      > Would this kind of circular reference even work?[/color]

      No. Circular references aren't supported in VB.Net.

      Look at Interfaces. Use these to define:
      (a) what the Library looks like to /any/ control,
      (b) what /every/ control looks like to the Library,
      (c) (possibly even) what each control looks like to /another/ control.

      Something like

      Interface ILibrary
      Public Sub Method1()
      Public Sub Method2()
      End Interface

      Interface ICustomControl
      Public Show Show()
      Public Show ShowDialog()
      End Interface

      Place of all these Interfaces into a third, shared library that is
      referenced by both of the other two. Now, your circular references
      have been extracted into this third assembly - so no problem there -
      and each object knows "enough" about the others (as defined in the
      Interfaces) to get on with whatever they all need to do.

      HTH,
      Phill W.


      Comment

      Working...