Cross Reference Assemblies

I have three projects in my .net solution.
The main project and two projects of the class library.

I found out that I need to cross-reference class library projects.
Can I do it? How safe is this or is there some consideration?

+4
source share
4 answers

The IDE will not let you when projects are in one solution. There are subtle ways to embarrass him. But then the solution cannot be built from scratch (i.e. Build + Rebuild), because the assembly reference is not yet available. Refactor this, you probably want the 3rd assembly to reference.

+3
source

Circular links are possible (via the command line and some tricks, not through the IDE), but are a major pain; do not do this!

Either add an additional assembly for generic types, or combine the two libraries.

In many ways, a smaller number is simpler ... A lot of DLLs don't mean you are clean - it's just a mess.

+3
source

When I ran into this problem, I have created classes that have only properties. May be Employee , Customer , Product , whatever. These classes should not refer to any other project, therefore several projects can refer to them.

The methods that belong to these objects ( Employee , Customer , Product ) then go into their own classes in other projects.

One of the situations when I met this quite often is a three-layer application - presentation layer, business layer and data access layer. I want the DAL to retrieve data and populate the Employee object that is returned by the BLL. If the Employee class is in the BLL and has both properties and methods, then there is no easy way to populate the Employee object in the DAL and return it to the BLL - since the BLL must have a reference to the DAL, so the DAL cannot in turn refer to the BLL. Creating a separate project with properties of only classes ( Employee , Customer , Product ) is one way to solve this problem.

+2
source

If using the "cross reference" link you want to do the following:

1) The MAIN project contains links to LIBRARY-ALPHA and LIBRARY-BETA

2) The LIBRARY-ALPHA project contains links to the LIBRARY-BETA

3) The LIBRARY-BETA project contains links to the LIBRARY-ALPHA

then no. Visual Studio cannot create MAIN until it creates ALPHA and BETA . He cannot build ALPHA until he builds BETA . And he cannot build BETA until he builds ALPHA . Therefore, he cannot build anything.

+1
source

Source: https://habr.com/ru/post/1334095/


All Articles