开发者

I can't load my configuration file in my C# Application

I'm using a config file in my Library project in order to associate the interfaces with their own classes; I'm having troubles since my Application can't load anything from the config. Here is a sample from the config file,which is called app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key=开发者_开发问答"Sic2Lib.it.carrefour.sic.profiler.datasource.def.AuthenticateDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.AuthenticateDSImpl"/>
    <add key="Sic2Lib.it.carrefour.sic.profiler.datasource.def.CheckUserDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.CheckUserDSImpl"/>
    <add key="Sic2Lib.it.carrefour.sic.profiler.datasource.def.ReadApplicationConfigDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.ReadApplicationConfigDSImpl"/>

Which is held in the same directory of the DataSourceFactory Class. This class is supposed to take the setting through the command

NameValueCollection keys = ConfigurationManager.AppSettings;

So, I build the project with no errors and I get a file called myProject.dll.confing in the bin/Debug folder. But after all this I always get the keys variable empty...How come? What's wrong with what I've done so far?


Library projects do not have their own configuration - they use the configuration from the application that uses the library.

Put the configuration settings in the configuration file of the application project and you should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜