Can a class library have an App.config file?

后端 未结 7 1153
别跟我提以往
别跟我提以往 2020-11-27 04:04

Here is what my solution is looking like at the moment:

\"enter

In the Tutomen

7条回答
  •  面向向阳花
    2020-11-27 04:58

    While this is an older thread, It does warrent another look.

    It seems you may want to look at the issue in a different way.

    Class libraries by nature are supposed to be portable. So, any configuration needed should be passed to the class, instead of residing with the library. Things like connection strings are by nature transitory, so it makes sense to put them in the owning application.

    When utilizing the methods contained in the library, you pass any needed information as part of the method's signature, or as a public property in the class. I suggest you create public properties for your configuration items, and pass them when you instantiate the class.

    Now you have no issues with an app.config for the DLL, and the DLL is then truly portable.

提交回复
热议问题