|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Circular References...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 Tom,
It is definitely not recommended. You should put MyNewForm into another assembly or in the same assembly that contains MyControl. Brian Tom wrote: Show quoteHide quote > 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 "Tom" <tom@nospam.com> wrote in message No. Circular references aren't supported in VB.Net.news:uWhJYw0eFHA.2244@TK2MSFTNGP15.phx.gbl... > 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. .. . . > Would this kind of circular reference even work? 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. |
|||||||||||||||||||||||