嵌入我发布的WinForms应用程序的.dll.config

问题描述 投票:0回答:1

我在

Windows Forms
中开发了一个
VS2022
应用程序,其中有几个 int 类型的
User Settings
,以便当用户修改某些参数时,它们的值将被保存并在下一次应用程序执行中加载。这在我的项目中生成了一个具有
App.config
Build Action->None
属性的
Copy to Output Directory->Do not copy
xml 文件。

当我发布我的应用程序(使用发布选项

Produce single file
)时,我的输出目录中会生成 3 个文件:
.exe
.pdb
.dll.config
文件。

如果我将

.exe
移动到其他文件夹,启动它时会抛出以下异常:

System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize`

所以它似乎依赖于与

.dll.config
文件位于同一目录中。

我尝试将

App.config
s
Build Action
设置为
Embedded Resource
但它仍然引发异常,这种依赖关系有解决方法吗?

c# visual-studio winforms
1个回答
0
投票

您可以尝试添加

<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
进入 pubxml 文件。

© www.soinside.com 2019 - 2024. All rights reserved.