小编Jim*_*der的帖子

在“设置”中内置时无法访问 App.config

我有一个非常简单的应用程序,我正在尝试使用 Settings 属性构建 app.config 。app.config 已构建,但运行时,键未检索值。

我最初使用的是从项目中添加应用程序配置文件并手动构建 app.config,并取得了巨大成功手动构建的 app.config 如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <appSettings>
    <add key="Hosppath" value="C:\events\inbound"/>
    <add key="Vendpath" value="C:\events\outbound"/>
    <add key="Hospname" value="OBLEN_COB_Active_Inv_Advi_Daily_.csv"/>
    <add key="Vendname" value="Advi_OBlen_Active_Inv_Ack_Daily_.csv"/>
    <add key="Hospkey" value="invoice_number"/>
    <add key="Vendkey" value="invoice"/>
    <add key="Outpath" value="C:\events\Reports"/>
    <add key="Outname" value="OB_Exception_Report_.xlsx"/>
    <add key="Hospexcpt" value="O'Bleness Exceptions"/>
    <add key="Vendexcpt" value="AdviCare Exceptions"/>
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

调用类在这里:

using System;
using System.Configuration;

namespace LoadSettings
{
    public static class ConfigReader
    {
        public static bool ReadAllSettings()
        {
            var success = false;
            var appSettings …
Run Code Online (Sandbox Code Playgroud)

c# configurationmanager app-config appsettings application-settings

2
推荐指数
1
解决办法
3192
查看次数