在使用vs2005开发3层结构(数据层、逻辑层和表示层)的应用程序时,数据层和表示层通常都又自己的配置文件;部署后的程序又只有表示层的配置文件(app.config或web.conifg)。那么如何部署数据层和逻辑层的配置文件(app.config)呢?

其实,很简单只好把数据层或逻辑层的配置文件“合并”到表示层的配置文件(app.config或web.conifg)中即可。

例如:
数据层的配置文件(app.config)如下:
部署数据层的配置文件(app.config)<?xml version="1.0" encoding="utf-8" ?>
部署数据层的配置文件(app.config)
<configuration>
部署数据层的配置文件(app.config)    
<configSections>
部署数据层的配置文件(app.config)    
</configSections>
部署数据层的配置文件(app.config)    
<connectionStrings>
部署数据层的配置文件(app.config)        
<add name="anjou.DataAccess.Properties.Settings.anjouConnectionString"
部署数据层的配置文件(app.config)            connectionString
="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\App_Data\db1.mdb;
                                                  Persist Security Info=True;Jet OLEDB:Database Password=123"

部署数据层的配置文件(app.config)            providerName
="System.Data.OleDb" />
部署数据层的配置文件(app.config)    
</connectionStrings>
部署数据层的配置文件(app.config)
</configuration>
表示层的配置文件(web.config)如下:
 1部署数据层的配置文件(app.config)<?xml version="1.0"?>
 2部署数据层的配置文件(app.config)<!-- 
 3部署数据层的配置文件(app.config)    注意: 除了手动编辑此文件以外,您还可以使用 
 4部署数据层的配置文件(app.config)    Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
 5部署数据层的配置文件(app.config)     “网站”->“Asp.Net 配置”选项。
 6部署数据层的配置文件(app.config)    设置和注释的完整列表在 
 7部署数据层的配置文件(app.config)    machine.config.comments 中,该文件通常位于 
 8部署数据层的配置文件(app.config)    \Windows\Microsoft.Net\Framework\v2.x\Config 中
 9部署数据层的配置文件(app.config)-->
10部署数据层的配置文件(app.config)<configuration>
11部署数据层的配置文件(app.config)    <appSettings/>
12部署数据层的配置文件(app.config)  <system.web>
13部署数据层的配置文件(app.config)        <!-- 
14部署数据层的配置文件(app.config)            设置 compilation debug="true" 将调试符号插入
15部署数据层的配置文件(app.config)            已编译的页面中。但由于这会 
16部署数据层的配置文件(app.config)            影响性能,因此只在开发过程中将此值 
17部署数据层的配置文件(app.config)            设置为 true。
18部署数据层的配置文件(app.config)        -->
19部署数据层的配置文件(app.config)        <compilation debug="true"/>
20部署数据层的配置文件(app.config)        <!--
21部署数据层的配置文件(app.config)            通过 <authentication> 节可以配置 ASP.NET 使用的 
22部署数据层的配置文件(app.config)            安全身份验证模式,
23部署数据层的配置文件(app.config)            以标识传入的用户。 
24部署数据层的配置文件(app.config)        -->
25部署数据层的配置文件(app.config)        <authentication mode="Windows"/>
26部署数据层的配置文件(app.config)        <!--
27部署数据层的配置文件(app.config)            如果在执行请求的过程中出现未处理的错误,
28部署数据层的配置文件(app.config)            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
29部署数据层的配置文件(app.config)            开发人员通过该节可以配置
30部署数据层的配置文件(app.config)            要显示的 html 错误页
31部署数据层的配置文件(app.config)            以代替错误堆栈跟踪。
32部署数据层的配置文件(app.config)
33部署数据层的配置文件(app.config)        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
34部署数据层的配置文件(app.config)            <error statusCode="403" redirect="NoAccess.htm" />
35部署数据层的配置文件(app.config)            <error statusCode="404" redirect="FileNotFound.htm" />
36部署数据层的配置文件(app.config)        </customErrors>
37部署数据层的配置文件(app.config)        -->
38部署数据层的配置文件(app.config)    </system.web>
39部署数据层的配置文件(app.config)</configuration>

合并后的表示层的配置文件(web.config)如下:
 1部署数据层的配置文件(app.config)<?xml version="1.0"?>
 2部署数据层的配置文件(app.config)<!-- 
 3部署数据层的配置文件(app.config)    注意: 除了手动编辑此文件以外,您还可以使用 
 4部署数据层的配置文件(app.config)    Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
 5部署数据层的配置文件(app.config)     “网站”->“Asp.Net 配置”选项。
 6部署数据层的配置文件(app.config)    设置和注释的完整列表在 
 7部署数据层的配置文件(app.config)    machine.config.comments 中,该文件通常位于 
 8部署数据层的配置文件(app.config)    \Windows\Microsoft.Net\Framework\v2.x\Config 中
 9部署数据层的配置文件(app.config)-->
10部署数据层的配置文件(app.config)<configuration>
11部署数据层的配置文件(app.config)    <appSettings/>
12部署数据层的配置文件(app.config)  <connectionStrings>
13部署数据层的配置文件(app.config)    <add name="anjou.DataAccess.Properties.Settings.anjouConnectionString"
14部署数据层的配置文件(app.config)        connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\App_Data\db1.mdb;
                                                  Persist Security Info=True;Jet OLEDB:Database Password=123"

15部署数据层的配置文件(app.config)        providerName="System.Data.OleDb" />
16部署数据层的配置文件(app.config)  </connectionStrings>
17部署数据层的配置文件(app.config)  <system.web>
18部署数据层的配置文件(app.config)        <!-- 
19部署数据层的配置文件(app.config)            设置 compilation debug="true" 将调试符号插入
20部署数据层的配置文件(app.config)            已编译的页面中。但由于这会 
21部署数据层的配置文件(app.config)            影响性能,因此只在开发过程中将此值 
22部署数据层的配置文件(app.config)            设置为 true。
23部署数据层的配置文件(app.config)        -->
24部署数据层的配置文件(app.config)        <compilation debug="true"/>
25部署数据层的配置文件(app.config)        <!--
26部署数据层的配置文件(app.config)            通过 <authentication> 节可以配置 ASP.NET 使用的 
27部署数据层的配置文件(app.config)            安全身份验证模式,
28部署数据层的配置文件(app.config)            以标识传入的用户。 
29部署数据层的配置文件(app.config)        -->
30部署数据层的配置文件(app.config)        <authentication mode="Windows"/>
31部署数据层的配置文件(app.config)        <!--
32部署数据层的配置文件(app.config)            如果在执行请求的过程中出现未处理的错误,
33部署数据层的配置文件(app.config)            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
34部署数据层的配置文件(app.config)            开发人员通过该节可以配置
35部署数据层的配置文件(app.config)            要显示的 html 错误页
36部署数据层的配置文件(app.config)            以代替错误堆栈跟踪。
37部署数据层的配置文件(app.config)
38部署数据层的配置文件(app.config)        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
39部署数据层的配置文件(app.config)            <error statusCode="403" redirect="NoAccess.htm" />
40部署数据层的配置文件(app.config)            <error statusCode="404" redirect="FileNotFound.htm" />
41部署数据层的配置文件(app.config)        </customErrors>
42部署数据层的配置文件(app.config)        -->
43部署数据层的配置文件(app.config)    </system.web>
44部署数据层的配置文件(app.config)</configuration>

相关连接:http://www.cnblogs.com/anjou/archive/2006/08/27/487860.html

相关文章: