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