连接App.Config文件 - 部署App.Config文件 [英] Wiring up an App.Config file - deploying the App.Config file

查看:124
本文介绍了连接App.Config文件 - 部署App.Config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


(这是正确的新闻组吗?)


===背景===

我正在构建一个包含两个项目的解决方案。


一个项目是我的数据访问层,它包含我的DataSet作为xsd

文件。 XSD文件是通过从数据源窗格中拖放表来构建的。

自动生成的代码创建了与XSD文件关联的文件(xss,

xsc,cs)。


另一个项目引用了数据访问层项目,

包含我的窗体表格。


===我的目标===(我的两个问题进一步说明了这个目标的部分内容。)

我想在解决方案中添加一个应用程序配置文件并让它包含

connectionstring。我希望能够在部署

之后编辑这个App.Config文件,以便我可以连接到所需的目标数据库。


===问题# 1 ===

这个问题是关于在已配置的XSD文件已经配置后添加App.Config文件:


在我添加App.Config文件后创建XSD文件时,

connectionString会自动添加到配置文件中,而XSD会自动连接到应用程序。配置文件。


但是,当XSD文件首先创建XSD并且App.Config文件

彼此独立时 - 不会发生自动连线。如何获得连接到XSD文件的App.Config文件

? - 我无法编辑与XSD文件关联的任何

文件,因为代码是自动生成的。


#1)如何添加应用程序。使用

现有的XSD文件将文件传输到数据访问层项目并让它们相互适当连接?


===问题#2 ===

这个问题是关于数据访问层中有一个

App.Config文件时应用程序的部署:


以下测试解决方案场景说明了我的问题:


我创建了一个测试解决方案,其中我添加了一个数据访问层项目(DAL)

并添加构建XSD文件之前的App.Config文件。我通过在设计图面添加一个表来构建XSD

文件。 (app.config和xsd

会自动正确连线。)然后我添加了一个Windows窗体项目

(WinFrmPrj)并添加对DAL的引用并添加一个带有

dataGridView的表单,并将其连接起来以显示数据表。我构建了一个发布

版本的项目。


查看相应的bin \ release文件夹结构,我看到以下内容:


DAL\bin\Release

- DAL.dll

- DAL.dll.config

- DAL。 pdb


WinFrmPrj\bin \ release

- DAL.dll

- DAL.pdb

- WinFrmPrj.exe

- WinFrmPrj.pdb

- WinFrmPrj.vshost.exe


第二个文件夹的内容" WinFrmPrj\bin\release"是什么得到

部署(据我所知),因此配置文件不可用!所以

当我部署到目标机器时我没有配置文件可以编辑到目标

应用程序到所需的数据库。


#2)如何在部署后使用''DAL.dll.config''或任何可编辑的配置文件

以便可以编辑它


感谢您的帮助。


dbuchanan

解决方案

让''看看我是否可以解决你的问题:


首先,您可以通过右键单击

并选择使用该应用程序来部署.config文件添加到编译中。这适用于更改

连接字符串。但是,配置始终处于应用程序级别,而不是
库级别。这意味着您必须通过在那里添加连接字符串

来更改

应用程序的应用程序配置(通过您的示例显示窗体)。即使你在图书馆一级创建,你也需要移动字符串。

在Orcas中变得容易得多。


其次,TableAdapters就是你的地方真的很担心,而不是

XSD。在大多数情况下,将XSD设置为特定数据库这一事实是一个小问题,即b $ b不方便。要重新连接,要么重新创建XSD(最坏情况)

,要么右键单击XSD并选择重新配置XSD的菜单项

(忘记选项的名称)。另一个选项是创建指向正确数据库的任何XSD

,并找到它在XSD下创建的实际代码中拉出

连接字符串的点。您可以

然后更改该代码。然而,在VS 2005中,这有点痛苦。我没有钻研这个,所以我不知道你要去哪里看看。


-

Gregory A Beamer

MVP; MCP:+ I,SE,SD,DBA
http://gregorybeamer.spaces。 live.com

合着者:Microsoft Expression Web Bible(即将发布)


************ ************************************

在盒子外面思考!

******************************************* *****

" dbuchanan" < db ******* @ newsgroup.nospamwrote in message

news:OF ************** @ TK2MSFTNGP06.phx.gbl ...


您好,


(这是正确的新闻组吗?)


===背景===

我正在构建一个包含两个项目的解决方案。


一个项目是我的数据访问层,它包含我的DataSet作为xsd

档案。 XSD文件是通过从数据源窗格中拖放表来构建的。

自动生成的代码创建了与XSD文件关联的文件(xss,

xsc,cs)。


另一个项目引用了数据访问层项目,

包含我的窗体表格。


===我的目标===(我的两个问题进一步说明了这个

目标的部分内容。)

我想在解决方案中添加一个app配置文件并拥有它包含

连接字符串。我希望能够在部署

之后编辑这个App.Config文件,以便我可以连接到所需的目标数据库。


===问题# 1 ===

这个问题是关于在已配置的XSD文件已经配置后添加App.Config文件:


在我添加App.Config文件后创建XSD文件时,

connectionString会自动添加到配置文件中,而XSD会自动连接到应用程序。配置文件。


但是,当XSD文件首先创建XSD并且App.Config

文件彼此独立时 - 不会发生自动连线。

如何才能将App.Config文件连接到XSD文件? - 我无法编辑

与XSD文件关联的任何文件,因为代码是

自动生成。


# 1)如何将App.Config文件添加到具有

现有XSD文件的数据访问层项目中并使它们相互适当连接?


===问题#2 ===

这个问题是关于数据访问层中有一个

App.Config文件时应用程序的部署: br />

以下测试解决方案场景说明了我的问题:


我创建了一个测试解决方案,其中我添加了一个数据访问层项目(DAL)

并在构建XSD文件之前添加了App.Config文件。我通过在设计图面添加一个表来构建

XSD文件。 (app.config和

xsd会自动正确连线。)然后我添加了一个Windows窗体

项目(WinFrmPrj)并添加对DAL的引用并添加一个带有

dataGridView的表单,并将其连接起来以显示数据表。我构建了一个发布

版本的项目。


查看相应的bin \ release文件夹结构,我看到了

以下:


DAL\bin\Release

- DAL.dll

- DAL.dll.config

- DAL.pdb


WinFrmPrj \ bin \\ \\ _发布

- DAL.dll

- DAL .pdb

- WinFrmPrj.exe

- WinFrmPrj.pdb

- WinFrmPrj.vshost.exe


第二个文件夹WinFrmPrj \ bin \ release的内容是什么得到

部署(据我所知),因此配置文件不可用!所以

当我部署到目标机器时我没有配置文件要编辑到

将应用程序定位到所需的数据库。


#2)如何在部署后使用''DAL.dll.config''或任何可编辑的配置文件

,以便可以对其进行编辑


感谢您的帮助。


dbuchanan



Hello Gregory,


#1 - 问题:


首先,您可以通过右键单击

并选择将其添加到编辑中。



这个选项在哪里?当我右键单击解决方案资源管理器中的文件

我看到这些:

打开

打开...

从项目中排除

剪切

复制

删除

重命名

属性


当我右键单击App.Config的设计图面时,我看到:

查看数据网格

插入片段.. 。

Surround With ...

转到定义

断点>

转到反汇编
剪切

复制

粘贴

概述>

属性


那么如何将App.Config文件部署到应用程序版本文件夹中?


#2 - 问题:


配置始终处于应用程序级别而不是库级别...

即使您在库级别创建...



应用程序级别是什么意思?和库级别?


#3 - 问题:


TableAdapters是你真正担心的地方,不是XSD



为什么? TableAdapters直接引用XSD,如果XSD是正确的,那么
不会使TableAdapter正常运行吗?


#4 - 问题:
< blockquote class =post_quotes>
要重新连接,要么......或者右键单击XSD并选择菜单项

重新配置XSD(忘记选项的名称)。



我在哪里右键单击XSD?当我右键单击解决方案中的XSD文件时

explorer我看到了:

打开

打开...

从项目中排除

减少

复制

删除

重命名




当我右键点击设计图面时,我看到:

添加

粘贴

选择全部

显示关联标签

预览数据...

查看代码

属性


我相信我已经能够以这种方式解决布线问题;


我将App.Config文件添加到数据访问层项目中。然后,通过

编辑

项目属性下的Settings.Settings中的值(ConnectionString),它会自动将connectionString值添加到

..config文件(以及将connectionString添加到

Settings.Designer.cs文件中)。在发布版本之后,配置

文件出现在dataAccessLayer \ bin \ Release文件夹中。 - 但.config

文件没有出现在Application\bin\ Release文件夹中。那仍是

大问题!


#5 - 问题:

最后一个问题。我有一个MSDN Pro订阅,我有权决定如何构建此应用程序。您是否建议我使用Visual Studio 2007(Orcas)完成此项目?
?是否有一个简单的

学习曲线? (顺便说一句,我正在使用Vista x64,如果它有任何

的影响。)


摘要:

接线是已解决。

部署未解决。

请回复上述问题。


谢谢,


dbuchanan


" Cowboy(Gregory A. Beamer)" < No ************ @ comcast.netNoSpamMwrote

消息新闻:uD ************** @ TK2MSFTNGP03.phx .gbl ...


让我们看看我是否可以解决你的问题:


首先,你可以拥有通过右键单击

并选择将其添加到编译中,使用应用程序部署.config文件。这对于更改连接字符串来说很好。但是,配置始终处于应用程序

级别而不是库级别。这意味着您必须通过在那里添加

连接字符串来更改应用程序的应用程序配置

(通过您的示例显示窗体)。即使你在图书馆一级创建,也需要

移动字符串。在Orcas中它变得容易得多。


其次,TableAdapters是你真正担心的地方,而不是

XSD。在大多数情况下,将XSD设置为特定数据库这一事实是一个小问题,即b $ b不方便。要重新连接,要么重新创建XSD(最差

的情况),要么右键单击XSD并选择重新配置XSD的菜单项(忘记选项的名称)。另一种选择是创建指向正确数据库的任何
XSD,并找到它在XSD下创建的实际代码中拉出

连接字符串的点。您可以

然后更改该代码。然而,在VS 2005中,这有点痛苦。我没有钻研这个,所以我不确定你要去哪里看。



-

Gregory A. Beamer

MVP; MCP:+ I,SE,SD,DBA
http://gregorybeamer.spaces。 live.com

合着者:Microsoft Expression Web Bible(即将发布)


************ ************************************

在盒子外面思考!

******************************************* *****

" dbuchanan" < db ******* @ newsgroup.nospamwrote in message

news:OF ************** @ TK2MSFTNGP06.phx.gbl ...


>你好,

(这是正确的新闻组吗?)

===背景== =
我正在构建一个包含两个项目的解决方案。

一个项目是我的数据访问层,它包含我的DataSet作为xsd
文件。 XSD文件是通过从数据源窗格中拖放表来构建的。自动生成的代码创建了与XSD文件关联的文件
(xss,xsc,cs)。

另一个项目引用了数据访问层项目,
包含我的窗户形式。

===我的目标===(我的两个问题进一步说明了这个目标的一部分。)
我想添加一个应用配置文件到解决方案并让它包含
连接字符串。我希望能够在部署之后编辑这个App.Config文件,以便我可以连接到所需的目标数据库。

===问题#1 ===
这个问题是关于在已配置XSD文件后添加App.Config文件:

我在添加App.Config文件后创建XSD文件时
connectionString自动添加到配置文件中,XSD自动连接到App.Config文件。

但是,首先创建XSD文件XSD和App.Config
文件彼此独立 - 没有自动接线。如何将App.Config文件连接到XSD文件? - 我无法编辑与XSD文件关联的任何文件,因为代码是自动生成的。

#1)如何添加App.Config文件到一个带有现有XSD文件的数据访问层项目,并将它们相互适当连接起来?

===问题#2 ===
这个问题是关于部署的当数据访问层中有一个App.Config文件时应用程序:

以下测试解决方案场景说明了我的问题:

我创建了一个测试解决方案我添加了一个数据访问层项目(DAL)
并在构建XSD文件之前添加了App.Config文件。我通过在设计图面添加一个表来构建
XSD文件。 (app.config和
xsd会自动正确连接。)然后我添加了一个Windows窗体
项目(WinFrmPrj)并添加了对DAL的引用并添加了一个带有
的表单dataGridView并将其连接起来以显示数据表。我构建了一个
发布版本的项目。

查看相应的bin \ release文件夹结构,我看到
以下内容:

DAL \\ _ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ - DAL.dll
- DAL.pdb
- WinFrmPrj.exe
- WinFrmPrj.pdb
- WinFrmPrj.vshost.exe

第二个文件夹WinFrmPrj \ bin \ release是什么得到部署(据我所知),因此配置文件不可用!
因此,当我部署到目标机器时,我没有要编辑的配置文件来将应用程序定位到所需的数据库。

#2)如何在部署后使用''DAL.dll.config'或任何可编辑的配置文件
以便可以编辑它? >
感谢您的帮助。

dbuchanan



嗨dbuchanan,


..NET只能为每个AppDomain加载一个默认配置文件(默认情况下是
默认的.exe.config与执行程序集),如果.exe使用

另一个.dll程序集,.dll程序集不能有自己的配置

文件。


在你的情况下,DAL项目在设计时拥有它自己的app.config,但是当它被应用程序使用时它是b $ b,它是从主应用程序中读取的。 />
config用户档案。因此,您必须将DAL项目中的连接字符串

键合并到主应用程序项目的配置

文件中。


希望这会有所帮助。

问候,

Walter Wang(wa****@online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


============================ ======================

在回复帖子时,请回复群组通过你的新闻阅读器

其他人可以从你的问题中学习并从中受益。

==================== ==============================

此帖子提供按现状 ;没有保证,也没有授予任何权利。


Hello,

(Is this the proper newsgroup?)

=== Background ===
I am building a solution with two projects.

One project is my data access layer which contains my DataSet as an xsd
file. The XSD file was built by draging tables from the Data Sources pane.
Auto-generated code created the files associated wtih the XSD file (xss,
xsc, cs).

The other project has a reference to the data access layer project and
contains my windows forms.

=== My Goal === (My two questions further down address parts of this goal.)
I want to add an app config file to the solution and have it contain the
connectionstring. I want to be able to edit this App.Config file after
deployment so that I can connect to the desired target database.

=== Question #1 ===
This question is about adding an App.Config file after the XSD file is
already configured:

When I create an XSD file after I add an App.Config file the
connectionString is automatically added to the config file and the XSD is
automatically wired up to the App.Config file.

However, when the XSD file is created first teh XSD and the App.Config file
are independant form one another - no automatic wiring occurs. How can I get
the App.Config file wired up to the XSD file? - I cannot edit any of the
files associated with the XSD file because the code is auto-generated.

#1) How do I add a App.Config file to a data access layer project with an
existing XSD file and have them appropriately wired up to each other?

=== Question #2 ===
This question is about deployment of the application when there is an
App.Config file in the data access layer:

The following test solution scenario illustrates my problem:

I created a test solution where I added a data access layer project (DAL)
and added the App.Config file before building the XSD file. I built the XSD
file by adding a table to the design surface. (the app.config and the xsd
are automatically wired up properly.) Then I added a windows form project
(WinFrmPrj) and add a reference to the DAL and added a form with a
dataGridView and wired it up to display a table of data. I built a Release
version of the project.

Looking at the respective bin\release folder structures I see the following:

DAL\bin\Release
- DAL.dll
- DAL.dll.config
- DAL.pdb

WinFrmPrj\bin\release
- DAL.dll
- DAL.pdb
- WinFrmPrj.exe
- WinFrmPrj.pdb
- WinFrmPrj.vshost.exe

The contents of the second folder "WinFrmPrj\bin\release" is what gets
deployed (as I understand), therefore the config file is not available! So
when I deploy to the target machine I have no config file to edit to target
the application to the desired database.

#2) How do I have the ''DAL.dll.config'' or any editable config file available
after deployment so that it can be edited

Thank you for your help.

dbuchanan

解决方案

Let''s see if I can cover your issues:

First, you can have the .config file deploy with the app by right clicking
and choosing to have it added to the compilation. This is fine for changing
connection strings. But, the config is always at application level and not
library level. This means you have to change the app config for the
application (windows forms by your example) by adding the connection string
there. Even if you created at library level, you need to move the string up.
It gets much easier in Orcas.

Second, the TableAdapters are where you are really worried about, not the
XSD. The fact that the XSD is set to a particular database is a minor
inconvenience in most cases. To rewire, either recreate the XSD (worst case)
or right click the XSD and choose the menu item that reconfigures the XSD
(forget the name of the option). The other option is to create any XSD
pointed to the correct database and find the point where it pulls the
connection string in the actual code created underneath the XSD. You can
then alter that code. In VS 2005, however, this is a bit of a pain. I have
not delved into this, so I am not sure where you have to look.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"dbuchanan" <db*******@newsgroup.nospamwrote in message
news:OF**************@TK2MSFTNGP06.phx.gbl...

Hello,

(Is this the proper newsgroup?)

=== Background ===
I am building a solution with two projects.

One project is my data access layer which contains my DataSet as an xsd
file. The XSD file was built by draging tables from the Data Sources pane.
Auto-generated code created the files associated wtih the XSD file (xss,
xsc, cs).

The other project has a reference to the data access layer project and
contains my windows forms.

=== My Goal === (My two questions further down address parts of this
goal.)
I want to add an app config file to the solution and have it contain the
connectionstring. I want to be able to edit this App.Config file after
deployment so that I can connect to the desired target database.

=== Question #1 ===
This question is about adding an App.Config file after the XSD file is
already configured:

When I create an XSD file after I add an App.Config file the
connectionString is automatically added to the config file and the XSD is
automatically wired up to the App.Config file.

However, when the XSD file is created first teh XSD and the App.Config
file are independant form one another - no automatic wiring occurs. How
can I get the App.Config file wired up to the XSD file? - I cannot edit
any of the files associated with the XSD file because the code is
auto-generated.

#1) How do I add a App.Config file to a data access layer project with an
existing XSD file and have them appropriately wired up to each other?

=== Question #2 ===
This question is about deployment of the application when there is an
App.Config file in the data access layer:

The following test solution scenario illustrates my problem:

I created a test solution where I added a data access layer project (DAL)
and added the App.Config file before building the XSD file. I built the
XSD file by adding a table to the design surface. (the app.config and the
xsd are automatically wired up properly.) Then I added a windows form
project (WinFrmPrj) and add a reference to the DAL and added a form with a
dataGridView and wired it up to display a table of data. I built a Release
version of the project.

Looking at the respective bin\release folder structures I see the
following:

DAL\bin\Release
- DAL.dll
- DAL.dll.config
- DAL.pdb

WinFrmPrj\bin\release
- DAL.dll
- DAL.pdb
- WinFrmPrj.exe
- WinFrmPrj.pdb
- WinFrmPrj.vshost.exe

The contents of the second folder "WinFrmPrj\bin\release" is what gets
deployed (as I understand), therefore the config file is not available! So
when I deploy to the target machine I have no config file to edit to
target the application to the desired database.

#2) How do I have the ''DAL.dll.config'' or any editable config file
available after deployment so that it can be edited

Thank you for your help.

dbuchanan



Hello Gregory,

#1 - Question:

First, you can have the .config file deploy with the app by right clicking
and choosing to have it added to the compilation.

Where is this that option? When I right click the file in solution explorer
I see these:
Open
Open With...
Exclude From Project
Cut
Copy
Delete
Rename
Properties

When I right-click the design surface of the App.Config I see:
View Data Grid
Insert Snippet...
Surround With...
Go To Definition
Breakpoint >
Go To Disassembly
Cut
Copy
Paste
Outlining >
Properties

So how do I deploy the App.Config file into the applicaton release folder?

#2 - Question:

the config is always at application level and not library level...
Even if you created at library level...

What do you mean by "application level" and "library level"?

#3 - Question:

the TableAdapters are where you are really worried about, not the XSD

Why? the TableAdapters refer directly to the XSD and if the XSD is right
will not the TableAdapter function properly?

#4 - Question:

To rewire, either ... or right click the XSD and choose the menu item that
reconfigures the XSD (forget the name of the option).

Where do I right-click the XSD? When I right click the XSD file in solution
explorer I see this:
Open
Open With...
Exclude From Project
Cut
Copy
Delete
Rename
Properties

When I right-click the design surface I see:
Add
Paste
Select All
Show Relation Labels
Preview Data...
View Code
Properties

I believe I have been able to solve the wiring this way;

I added the App.Config file to the data access layer project. Then, by
editing the Value (ConnectionString) in the Settings.Settings under the
Project Properties it automatically added the connectionString value to the
..config file (along with adding the connectionString to the
Settings.Designer.cs file too). After doing a release building the config
file appeared in the dataAccessLayer\bin\Release folder. - But the .config
file did NOT appear in the Application\bin\Release folder. That is still the
big problem!

#5 - Question:
One last question. I have an MSDN Pro subscription and I have decision
authority for how this applicaiton is constructed. Would you suggest that I
complete this project using Visual Studio 2007 (Orcas)? Is there an easy
learning curve? (By the way I am working on Vista x64 if that has any
influence.)

Summary:
The wiring is solved.
The deployment is NOT solved.
Please reply to questions above.

Thank you,

dbuchanan

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:uD**************@TK2MSFTNGP03.phx.gbl...

Let''s see if I can cover your issues:

First, you can have the .config file deploy with the app by right clicking
and choosing to have it added to the compilation. This is fine for
changing connection strings. But, the config is always at application
level and not library level. This means you have to change the app config
for the application (windows forms by your example) by adding the
connection string there. Even if you created at library level, you need to
move the string up. It gets much easier in Orcas.

Second, the TableAdapters are where you are really worried about, not the
XSD. The fact that the XSD is set to a particular database is a minor
inconvenience in most cases. To rewire, either recreate the XSD (worst
case) or right click the XSD and choose the menu item that reconfigures
the XSD (forget the name of the option). The other option is to create any
XSD pointed to the correct database and find the point where it pulls the
connection string in the actual code created underneath the XSD. You can
then alter that code. In VS 2005, however, this is a bit of a pain. I have
not delved into this, so I am not sure where you have to look.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"dbuchanan" <db*******@newsgroup.nospamwrote in message
news:OF**************@TK2MSFTNGP06.phx.gbl...

>Hello,

(Is this the proper newsgroup?)

=== Background ===
I am building a solution with two projects.

One project is my data access layer which contains my DataSet as an xsd
file. The XSD file was built by draging tables from the Data Sources
pane. Auto-generated code created the files associated wtih the XSD file
(xss, xsc, cs).

The other project has a reference to the data access layer project and
contains my windows forms.

=== My Goal === (My two questions further down address parts of this
goal.)
I want to add an app config file to the solution and have it contain the
connectionstring. I want to be able to edit this App.Config file after
deployment so that I can connect to the desired target database.

=== Question #1 ===
This question is about adding an App.Config file after the XSD file is
already configured:

When I create an XSD file after I add an App.Config file the
connectionString is automatically added to the config file and the XSD is
automatically wired up to the App.Config file.

However, when the XSD file is created first teh XSD and the App.Config
file are independant form one another - no automatic wiring occurs. How
can I get the App.Config file wired up to the XSD file? - I cannot edit
any of the files associated with the XSD file because the code is
auto-generated.

#1) How do I add a App.Config file to a data access layer project with an
existing XSD file and have them appropriately wired up to each other?

=== Question #2 ===
This question is about deployment of the application when there is an
App.Config file in the data access layer:

The following test solution scenario illustrates my problem:

I created a test solution where I added a data access layer project (DAL)
and added the App.Config file before building the XSD file. I built the
XSD file by adding a table to the design surface. (the app.config and the
xsd are automatically wired up properly.) Then I added a windows form
project (WinFrmPrj) and add a reference to the DAL and added a form with
a dataGridView and wired it up to display a table of data. I built a
Release version of the project.

Looking at the respective bin\release folder structures I see the
following:

DAL\bin\Release
- DAL.dll
- DAL.dll.config
- DAL.pdb

WinFrmPrj\bin\release
- DAL.dll
- DAL.pdb
- WinFrmPrj.exe
- WinFrmPrj.pdb
- WinFrmPrj.vshost.exe

The contents of the second folder "WinFrmPrj\bin\release" is what gets
deployed (as I understand), therefore the config file is not available!
So when I deploy to the target machine I have no config file to edit to
target the application to the desired database.

#2) How do I have the ''DAL.dll.config'' or any editable config file
available after deployment so that it can be edited

Thank you for your help.

dbuchanan



Hi dbuchanan,

..NET can only load a default configuration file per AppDomain (which is by
default the .exe.config with the executing assembly), if the .exe uses
another .dll assembly, the .dll assembly cannot have its own configuration
file.

In your case, the DAL project has it''s own app.config at design time, but
when it''s used by the application, it''s reading from the main application''s
configuration file. Therefore you will have to merge the connection string
key from the DAL project into the main application project''s configuration
file.

Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于连接App.Config文件 - 部署App.Config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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