Page 1 of 1
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 11:36 am
by alex_schmitt
Hey all,
I am conducting my first attempts in migrating our project from VO and XS.
One thing I stumbled across was the following:
Assuming you have project A that uses a CLASS from project B and project B a CLASS from project A.
In VO it was possible to mutually reference between the two in the respective "Application Options" in the libraries tab.
- If you would compile say project A it would compile everything except the part where project B is referenced (as this is not yet compiled).
- So going back to project B and compiling project B it would compile everything except the part where project A is referenced.
- So compiling project A would now succeed.
- And finally, project B can be compiled.
Compiling project A in XS the compiler is looking for the DLL from project B, which is of course not there - and vice versa.
What would be the best practice to resolve this?
Best,
Alex
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 12:05 pm
by SHirsch
Hello Alex,
you may extract all classes that are used in both projects to a new base library. Then you can compile your base lib and then set a reference in project A and project B to your new base lib.
Regards
Stefan
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 1:21 pm
by alex_schmitt
Hey Stefan,
Thanks! I was fearing this step
But apparently now away around this. Apparently this is the cleanest way anyhow, even for VO.
Best,
Alex
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 1:58 pm
by robert
Alex,
You can also declare an interface for one of the classes and declare that interface in the other classlibrary.
Assume Class A and Class B, ClassLibrary A has Class A and ClassLibrary B has class B
You declare InterfaceB in classLibrary A and set a reference from ClassLibrary B to ClassLibrary A and add the "IMPLEMENTS InterfaceB" to the declaration of class B.
Inside ClassLibrary A you then replace the name ClassB with InterfaceB and it should work.
Robert
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 2:03 pm
by alex_schmitt
Thanks Robert!
While digging deeper I found a lot of inter-project dependencies and the most straightforward way would likely be to place everything into one library. There's only 2-3 EXEs making use of it so that should still be valid.
I'll give it a try. Everything else seems to depict major refactoring.
Best,
Alex
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 2:17 pm
by wriedmann
Hi Alex,
you can also do something different: define the objects "as object" and use CreateInstance() to create the objects. This was you can prepare your code on the VO side before migration.
Is is not the cleanest method, but IMHO the most simple one, and the only one that let you have the same code on both the VO and the X# side.
Wolfgang
P.S. IMHO VO should never have admit these circular references. I have seen a project with many circular referenced applications that takes several hours (!) to compile in VO.
Compiling DLLs cross-referencing each other
Posted: Sun Jan 09, 2022 7:34 pm
by alex_schmitt
Thanks, Wolfgang.
I could finally manage by merging all applications into one and it looks like I am on a good track with this.
I agree the circular references are not best practice at all, but as it worked and was convenient, I just used this
Best,
Alex
Compiling DLLs cross-referencing each other
Posted: Mon Jan 10, 2022 5:08 am
by wriedmann
Hi Alex,
merging into one application for sure is the easiest and safest option.
But when you are done with the migration you should think about splitting it up again in a different manner to make compilation times shorter.
Unlike VO (where only "dead" entities are compiled) the X# compiler (like the C# compiler) compiles the entire application every time.
Wolfgang
Compiling DLLs cross-referencing each other
Posted: Sun Jan 16, 2022 9:10 pm
by alex_schmitt
That's definitively a good hint, Wolfgang. I already see the differences in compile times