Circular DLL dependencies in .NET.

I have a DLL that provides an entry point to an ASP.MVC application. Name it Primary.DLL . Primary.DLL has a LINQ-to-SQL data context and other classes. Somewhere in Application_Start() , Assembly.Load() is called to load Secondary.DLL . Secondary is not mentioned in the project file Primary.DLL. But Primary is referenced in the Secondary.DLL project file because the LINQ-to-SQL data context and other classes mentioned above are used in Secondary.

Will this create a circular dependency problem? Will there be problems with this design?

+6
source share
3 answers

We do this all the time with the help of specialized client-specific DLL files. We use the same features in web applications, services, and desktop computers.

Client DLLs reference basic DLL projects so that they can inherit from various classes and implement interfaces. To do this, they must have a link to the base dll.

When starting the application ( global.asax Application_Start or the exe initialization procedure), we load all the detected DLL files for configuration through Assembly.Load , and it definitely does not create a cross reference.

+1
source

Assemblies do not load in AppDomain, and you load Secondary.dll in Application_Start, so this should not cause any problems and should not lead to the appearance of a circular dependency.

+1
source

It will not create a circular dependency problem, but it may not be a big design. Circular dependencies require an actual link between two or more projects.

+1
source

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


All Articles