在一个项目中使用2个配置文件时出现问题 [英] Problem in using 2 config files in one project

查看:62
本文介绍了在一个项目中使用2个配置文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在项目中使用2个配置文件.一个是Web.config,另一个是web1.config.
请参见下面的代码.但是,它不起作用.

实际上,我在完成项目后添加了web1.config文件,并且以所有形式使用了代码:

Hi,

I am using 2 config files in my project. One is Web.config and another is web1.config.
Please see the code below. But, it is not working.

Actually i added web1.config file after completing my project and in all form I used the code:

System.Configuration.ConfigurationManager.AppSettings("gridrows").ToString()



在web.config文件中:
appSettings configSource = Web1.config
在web1.config文件中:
appSettings
添加key = gridrows value = 10


[从答案中移出]

我正在使用vb.net并出现错误
"configSource文件的格式必须是包含节名称的元素."
我确实是这样的:



In web.config file:
appSettings configSource=Web1.config
In web1.config file:
appSettings
add key=gridrows value=10


[Moved from Answer]

I m using vb.net and getting error
"The format of a configSource file must be an element containing the name of the section."
I did like this:

gridMain.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings("gridrows").ToString())


[/从答案中移出]

推荐答案

实际上不错,但您仍然可以

尝试dis

Its actually fine but still u can

try dis

System.Configuration.ConfigurationManager.AppSettings["gridrows"].ToString() <br />


或参考.
http://goo.gl/vFQT

http://goo.gl/7lhi


or do refer..
http://goo.gl/vFQT
and
http://goo.gl/7lhi


其中您在根目录中添加了web.config文件或直接儿童....
where u add web.config file in root directory or child directiry....


这篇关于在一个项目中使用2个配置文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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