0

I essentially am in charge of a DLL for my project that uses lots of external resources. I want to have a config file for my project named infrastructure.config that clients projects can copy in their project without having to cut and paste into their own app or web configs. I tried the following suggestion at:

Change default app.config at runtime

That solution worked well until I tried with Log4Net which utilizes a custom section. I received an unknown configuration section when I tried to use the code in the above mentioned link. When I use the same configuration file without the above mentioned code it works fine. Interestingly enough, it blew up when I was trying to use TransactionScope. So some combination of using TransactionScope and having configurationSections in my config made it fail. Any suggestions?

I want each client app or web site to have their own config for its own values while my infrsatucture.dll should be able to have a combination of its own values, custom SOAP Bindings and Log4Net.

Community
  • 1
  • 1
user434290
  • 63
  • 8

1 Answers1

0

Sound like what Dependency Injection is good for solving.

I would highly suggest that instead of creating an application/dll that relies on a config file (app settings or sections), that your interface expose what it needs to do it's work. These can be external class/interfaces exposed by other DLLs (log4net) or you can create your own and allow other developers to derive concrete classes based on your required abstract/interfaces classes.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • That is essentially what is happening in reverse. The DLL which I am working on Infrasdtructure.dll is implementing Interfaces specified by a Core DLL. One of those interfaces is for logging. I am trying to avoid the practice of having each client copy configuration settings that are specific to the infrastructure.dll over to their config files. I was hoping that we could avoid that. Now if my DLL was a separate running process such as a web service this would not be an issue. I would just have my own config. However, on this project the architect wants to just use plain old DLL's. – user434290 Oct 01 '12 at 20:05