Page 1 of 1

How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 11:38 am
by Fergal
Ranorex 6.0.0, Windows 7

I have a solution which contains multiple projects, e.g. Project A and Project B. Today I was working on Project B and started using a code module from Project A, as part of 2 Test Cases in Project B. After doing this the solution would no longer build and gave the error below:

"Cyclic dependency between Project B and Project A".

To resolve the issue, I deleted both uses of the code module from the two TCs within Project B. However, the solution will still not build and is giving the same error.

How can I resolve this or find out exactly what is causing the error?

Thanks!

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 2:08 pm
by krstcs
The only solution to that problem is to not create the cyclical dependency.

The issue is that your solution A is using modules from B already, so B has to be compiled before A is compiled. Then you tried to have B use modules from A, which would mean that A would need to be compiled before B, but since B already has to be first, this won't work.

What you really need to do is create a library project in the solution and put all of your modules in that library and have all of your other projects depend only on that library. You could also create a separate solution for the library, but that causes other headaches.

I do this in all of my solutions, one project is the CORE and contains all the modules and the other projects are the tests and contain the suites.

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 2:28 pm
by Fergal
Thanks for explaining all of that krstcs.
krstcs wrote:The only solution to that problem is to not create the cyclical dependency...
I will keep that in mind for future solutions, but unfortunately it is too late in this instance :)

krstcs wrote:What you really need to do is create a library project in the solution and put all of your modules in that library and have all of your other projects depend only on that library...
Can I use that approach to fix my current solution? If not, how can I fix it?

Thanks again!

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 2:47 pm
by krstcs
Yes, you can use that now, just create a new project in your current solution. However you would need to re-create all of the modules that will be used by multiple projects in that new project.

Your best bet for now, if you don't want to do all of that work, is to either not use the modules from A in B, or recreate the modules in B (this is really not recommended though as it now means you have 2 places to make changes if you have to rework those modules).

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 3:05 pm
by Fergal
krstcs wrote:...you would need to re-create all of the modules that will be used by multiple projects in that new project....
By "re-create" I'm assuming you don't mean drag and drop or copy and paste?

I understand that it is not a good idea to copy and paste modules from one solution to another, does the same apply to copying and pasting modules between projects in the same solution?

Thanks!

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 3:29 pm
by krstcs
You are correct. It really isn't a good idea to copy-and-paste modules because of the GUIDs used behind-the-scenes to uniquely identify objects and members. If you drag a module that has a GUID in it somewhere that is already used by another module in the new project, then you run the very serious risk of causing very hard to debug errors. However, there may be new features in Ranorex 6.0 that allow this without issues.


So, when I say 'recreate' I mean create new modules in the new project. It may be possible to copy-and-paste the actual code inside certain parts of the original modules into the new ones, but you should exercise caution to ensure there are no issues.

Re: How to resolve a cyclic dependency error

Posted: Thu Jul 14, 2016 3:33 pm
by Fergal
Thanks for your help and the clarification krstcs.