2
所以这对我来说是一个新的。如何定义配置段
我想在我的类库中定义一个ConfigurationSection类,该类从我的WinForms应用程序中的App.Config中抽取。我从来没有这样做过,但从下面的例子,这是我必须的。
的app.config在我的WinForms应用程序
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ReportEngineConfig" type="Optima.ReportEngine.ReportEngineConfig" allowDefinition="Everywhere" allowLocation="true"/>
</configSections>
<ReportEngineConfig>
<ReportObjectVariableRegEx value="test" ></ReportObjectVariableRegEx>
</ReportEngineConfig>
</configuration>
在我单独类库我的ConfigurationSection类。
using System.Configuration;
namespace Optima.ReportEngine
{
public class ReportEngineConfig : ConfigurationSection
{
[ConfigurationProperty("ReportObjectVariableRegEx")]
public string ReportObjectVariableRegEx
{
get
{
return (string)this["value"];
}
}
}
}
所以任何机会,任何人都可以指出哪里我已经错了
谢谢!
我已经设置了线 <节名称=“ReportEngineConfig” TYPE =“Optima.ReportEngine .ReportEngineConfig,ReportEngine“allowDefinition =”Everywhere“allowLocation =”true“/> ReportEngine是dll的名称,但是这个[”value“]仍然得到空引用? – 2010-02-25 11:11:52