Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circular DLL dependencies in .NET

I have a DLL which provides an entry point to an ASP.MVC application. Let's call this Primary.DLL. In Primary.DLL, there are LINQ-to-SQL data context and other classes defined. Somewhere in Application_Start(), Assembly.Load() is called to load Secondary.DLL. Secondary is NOT referenced in Primary.DLL's project file. But Primary is referenced in the project file of Secondary.DLL because the LINQ-to-SQL data context and other classes mentioned above are used in Secondary.

Would this create a circular dependency problem? Would there be any problem with this kind of design?

like image 912
Kevin Le - Khnle Avatar asked Jan 16 '12 02:01

Kevin Le - Khnle


1 Answers

We do this all of the time with customer-specific customization DLLs. We use the same functionality in web applications, services, and desktop exes.

The customer DLLs reference the base project DLLs so that they can inherit from various classes and implement interfaces. To do so, they must have a reference to the base dll.

At application startup (global.asax Application_Start or an exe's initialization routine), we load any discovered customization DLLs through Assembly.Load and it definitely does not create a cross-reference.

like image 160
competent_tech Avatar answered Oct 16 '22 05:10

competent_tech