As part of a program I am developing for practice purposes, I've created a namespace Core
designed to contain the core code resources for the program to use. This namespace is in a Class Library project.
Two of the sub-namespaces in Core
are Core.Files
and Core.Errors
. In Core.Files
there is a TxtFile
class that is responsible for input-output to .txt files. In Core.Errors
there is an Error
class which is responsible for managing a specific error. The class API allows you to manage an error in three ways:
- Display the error to the user.
- Record the error in a log file.
- Perform both.
In the last two options, Error
depends on TxtFile
to record the error in the log file (using the Write()
method).
The Write()
method in TxtFile
is built in such a way that if it fails to write text into the file, Error
is instantiated. Since something is obviously not working in Write()
, the error is displayed to the user but not logged in the file.
Everything works great. Over time, however, the two namespaces grew, and I thought it would be appropriate to create a separate project for each of them.
The problem is that since Error
depends onTxtFile
and TxtFile
depends onError
, there is a circular dependency between the two projects, and it is impossible to add references between them.
This answer suggests that such a situation is an indication of bad design. How can I improve the design so that this problem does not occur? I want to preserve the structure of a single assembly per sub-namespace.
Thanks.