简体   繁体   中英

Force DLL (Class Library to use it's own app.config) in C#

For a specific reason, i need to create a WPF-DLL which uses a WCF service to get some data and then displays it when an application calls this WPF assembly. The WPF assembly, in turn, requires binding information which is written in an app.config. Is there a way to force the DLL to read the binding information in a seperate app.config?

Thanks in advance for the hint.

Best regards,

As a class library dll isn't executing, it won't use an app config. The idea being that multiple applications could use your library and pass slightly different values in, making your library dynamic and reusable.

If you need to pack in static values for some reason that aren't configured. You could consider a resource or settings file, or even a simple xml document called mylibrary.config.xml or whatever and manually parse it.

Go to App properties -> Settings tab; add your settings there.

Use Properties.Settings.Default.<SettingName> to access the setting. That's it!

It works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM