π‘ͺπ’Šπ’“π’„π’–π’π’‚π’“ π‘«π’†π’‘π’†π’π’…π’†π’π’„π’š (.NET)

Muhammad Waseem
1 min readNov 10, 2022

--

In this we would learn about

  1. What is Circular Dependency
  2. Reasons causing the Circular Dependency
  3. How Error Looks Like
  4. Solution

⏩𝑾𝒉𝒂𝒕 π’Šπ’” π‘ͺπ’Šπ’“π’„π’–π’π’‚π’“ π‘«π’†π’‘π’†π’π’…π’†π’π’„π’š?
Circular dependency is a relation between two entities (could be class, module or library)
Where first entity depends on second and second depends on first to work properly, kind of recursion.

⏩𝑹𝒆𝒂𝒔𝒐𝒏𝒔 π’„π’‚π’–π’”π’Šπ’π’ˆ π‘ͺπ’Šπ’“π’„π’–π’π’‚π’“ π‘«π’†π’‘π’†π’π’…π’†π’π’„π’š?
1) Library or Project
2) Classes or Interface (that is implementing some class eventually)
3) Methods

⏩𝑬𝒓𝒓𝒐𝒓 π’π’π’π’Œπ’” π’π’Šπ’Œπ’†
If any kind of circular dependency is happening in your application, you would see error like this.
𝙰 πšŒπš’πš›πšŒπšžπš•πšŠπš› πšπšŽπš™πšŽπš—πšπšŽπš—πšŒπš’ 𝚠𝚊𝚜 𝚍𝚎𝚝𝚎𝚌𝚝𝚎𝚍 πšπš˜πš› πšπš‘πšŽ πšœπšŽπš›πšŸπš’πšŒπšŽ 𝚘𝚏 πšπš’πš™πšŽ.

β©π‘Ίπ’π’π’–π’•π’Šπ’π’
Its solution is to make those classes/methods/projects independent from one side , if you keep both dependent it will cause a non-ending recursive call.

If you like my work you can help me in growing through following ways

  1. Connect with me on LinkedIn and Twitter
  2. Buy me a Coffee

--

--