Created a solution, there are two projects: the first is the presentation (UI), the second is the data access layer (DAL). In DAL created a configuration file.

I make a call from the UI of some methods located in the DAL and using the configuration file via ConfigurationManager.AppSettings . And ... nothing happens, nulls are returned. Suspicions have crept in that the configuration file is searched, as it were, in the current context (that is, in my case, in the UI project). I copied the configuration file to the UI project and it all worked.

The question arises, how to be? How to force ConfigurationManager to search for a configuration file in the context of the project in the project of which its direct call is located? Or maybe some other approach should be used?

  • Why do you need AppSettings in a UI project? Isn't that obviously a model thing? Something is wrong with your architecture. - VladD
  • @VladD is not needed in the UI, the call to AppSettings occurs in the DAL, which seems to be logical. If more, then everything happens like this: in the UI, for example, the DAL.GetAllProducts () method is called, and the GetAllProducts method is called AppSettings - Yes Man
  • Well, for starters, it's not a matter of the UI to access the model. But this is offtopic in relation to your question. You have the application itself (exe) for some reason, combined with the UI. This is in theory wrong. Let there be one mini-project in which the application and configuration, the UI-project as a library, and DAL as another library. - VladD

0