Re: Circular dependencies
If ClassLibrary1 is compiled first, it will be compiled against a pre-compiled version of BaseLibrary. This could (and probably will) cause runtime errors when trying to access a method that may no longer exist. The same would go if BaseLibrary is compiled first.
What I usually do is have 3 assemblies for large projects. An assembly that contains only the entry point (and maybe some configuration & loading stuff), an assembly that contains only UI (WinForms and embedded graphics), and one that contains all the data manipulation & storage classes.
If your having a problem with circular dependency then you may want to look at the purpose for each of your assemblies and figure out if you're staying within these boundaries. Its really easy to just create classes wherever without thinking which assembly its supposed to go in.
Hope this helps.
Re: Circular dependencies
in the case that VS does not let you set references between projects, this does not actually reflect any real circular dependency. in other words, VS will not allow you to establish a direct circular reference between projects, regardless of whether the code in the projects actually depends on the reference.
as far as actual circular references in your code (as opposed to the superficial check VS did above), it is certainly possible to create these without causing problems. after all, it is just a type of recursion.
an obvious significant problem we associate with circular references is that if they exist they may cause an infinite regression while the computer attempts to resolve references. despite your circular reference, this does not occur because your modal form is not automatically being instantiated with a form from ClassLibrary1. hence, there is a finite sequence of operations that must be performed to define the state of a ClassLibrary1 form at instantiation. if you were to change your code (i havent really read it) so that instantiation of FrmBase automatically instantiated a derived ClassLibrary1 form, you should get a stack overflow error. this time the error arises because the existence of a ClassLibrary1 form directly implies the existence of a distinct FrmBase instance, implies the existence of a new distinct ClassLibrary1 form instance, and so forth, ad infinitum.
edit: i should note that you might want to reconsider your design. :)
Re: Circular dependencies
Just to go into more detail from my prior post...
If Library1 has a project reference in VS to Library2. And Library2 has a direct reference to "Library1.dll" (the output of Library1), then Library2 will almost always be built against an out-of-date Library1.
- If Library1 is being built than VS will require Library2 to build first since there is a Project reference.
- Library2 will then copy over the already existing Library1.dll from the last time Library1 was built and do compilation checks against the classes and method difined in the old version of Library1.
- Then Library1 will be built against the new version of Library2.
If something were to be changed in Library1 that should cause a compilation error in Library2, I don't think Library2 will catch it until the 2nd time it is built because the 1st time it would be using the "library1.dll" from before the changes were built.
Re: Circular dependencies
Thanks for your replies - enfekted and Issa.
I have been thinking about this problem since yesterday and was begining to come to the same conclusion that I need to rethink my design.
I have decided to put the modal form in the baseLibrary itself. It goes against the basic rule we had established in our project group that the baselibrary should only contain bases classes that will be derived from, but I think this is a good case to bend the rule, since the modal form will only be called by the ChildBase form.
Thanks for your help again.
-Satish