That's what a dependency is, it's hierarchical, there must be a starting point. So when compiling your first project, the compiler will run into CustomClass1 definition, it knows it lays into Project2.dll and therefore will compile Project2 before, in order to be able to add that reference in your first project. Now, let's say you have, further in your class, the following definition 'Some code hereĪnd let's say CustomClass1 is defined in another project of yours, named Project2.DLL: Public Class CustomClass1 It will then link that DLL to your project, so at run-time, when defining or doing operation on the string, the System.dll will be loaded to perform those. When compiling your project, the compiler runs into the String class, which is defined in a DLL file called System. Let's say you have a project and, in a class, you have the following defined: Public Class M圜lass In order to understand what circular dependency is, it is better to understand what is a dependency and what it means to the compiler. You might get away with just splitting the classes up so that dependencies can be sorted that way without creating the third project. In this case you need to create a third project "C" which contains the classes that both A and B depend on so they no longer depend on each other. Re-designing in my case will mean define the same type in both projects, which I don't think that could be good practices neither. You'll only spot it when you try on a different machine that's never built the solution before or if you do a clean & build. If you introduce a circular dependency to a project that you've already built it can be hard to spot as the standard build options don't remove the existing object files thus enabling you to build A (or B) first. This is the problem that circular dependencies cause. This means to compile Project A you must first compile Project B, but you can't do that as B requires A to be compiled. is the worst idea I think.Ī circular dependency is where Project A depends on something in Project B and project B depends on something in Project A. Is the first time that I hear the term " Circular dependency" I've read this article from MSDN but I understood nothing.Īnyways I seen many questions of circular dependencys like this, and from what I've seen in that question seems that a circular dependency means that two projects cannot reference between them at the same time, just one of those two projects can reference the other Īnd also all the people who answered in that question said things like " Re-design is the solution" or " Circular dependencies are not good practices", however, re-designing in my case will mean define the same type in both projects, which I don't think that could be good practices neither, and of course building an additional assembly/project just to store a single type to reference that assembly in both projects. Someone could explain me with other simple words (maybe with a code example too in case of code is implied in the error) what is a circular dependency?, and the most important thing: what can I do to solve it? ( please read the last prhases of my research before answering). The problem is that when I try to add the project reference, I get this error message: Obviouslly, If I want to inherit the type defined in the first project, in the second project I need to add a project reference to the first project to be able see the type and go on. Well, in the first project I defined a inheritable class-type on which I would like that some classes from the second project inherits from it. The second project doesn't have a reference to the first project. The first project has a project reference to the second project. I have a solution on which I have (more than) 2 projects.
0 Comments
Leave a Reply. |