如何在类库中访问我的app.config文件 [英] How can I acces my app.config file in a class library

查看:172
本文介绍了如何在类库中访问我的app.config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友:

我有一个要访问其app.config文件的类库.在此配置文件中,我保存了一个指示我的strig连接的部分.我想访问此字符串连接.但是,当我在此类库类中使用以下代码时,我没有得到任何部分:

Dear Friends:

I have a class library that I want to access its app.config file. in this config file i saved a section indicating my strig connection. I want to access this string conncection. But, when I use the below code in this class library class I dont get any section:

ConnectionStringsSection ss = (ConnectionStringsSection)
ConfigurationManager .GetSection( "US1ConnectionString" );







or

ConnectionStringSettings s = ConfigurationManager .ConnectionStrings["US1ConnectionString"]



我的代码有什么问题?
我应该强调,这是一个类库类,我想访问其配置文件

Yours



What is wrong with my code??
I should emphasis that this is a class library class and I want to access its config file

Yours

推荐答案

一些文章可以帮助您-
使用.NET 2.0读取/写入App.Config文件 [ ^ ]
http://www.dreamincode.net/forums/topic/45321-grabbing-connectionstring -from-appconfig/ [ ^ ]
Some articles to help you out -
Read/Write App.Config File with .NET 2.0[^]
http://www.dreamincode.net/forums/topic/45321-grabbing-connectionstring-from-appconfig/[^]


这篇关于如何在类库中访问我的app.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆