代码之家  ›  专栏  ›  技术社区  ›  kobe

从控制台应用程序执行getconfig节时出现“未找到路径”错误

  •  0
  • kobe  · 技术社区  · 14 年前

    我正在尝试从控制台应用程序执行以下代码。

    ConfigurationSection aggregatedFileSection = (ConfigurationSection)config.GetSection("Aggregation.FileAggregationConfig");  // this is inside a web.config of main web project
    

    以下行位于web.config中。

    <Aggregation.FileAggregationConfig configSource="config\common\MyAggregation.Config" />
    

    上面的聚合在该项目的web.confg中有一个附加到它的HTTP处理程序。

    <section name="Aggregation.FileAggregationConfig" type="WebProj.AggregationConfigHanler, WEBPROJ"/>
    

    因为我正在从控制台应用程序获取配置部分,它在执行Web项目内的处理程序时找不到webproj路径。 引发错误,执行httphandler时找不到路径

    如果你知道在控制台应用程序中提供路径的任何方法,请告诉我好吗

    1 回复  |  直到 14 年前
        1
  •  1
  •   Saeed Amiri    14 年前

    您的配置文件将从 active 项目,在本例中是控制台应用程序配置文件。您应该在控制台应用程序的web.config中嵌入项目。