C# 从项目引用中读取appconfig

C# 从项目引用中读取appconfig,c#,configuration,app-config,C#,Configuration,App Config,在我的主项目(“演示”)中,我添加了对某个项目(“通用”)的项目引用。 在“Common”项目中,我有app.config文件,其中包含: <configuration> <appSettings> <add key="test" value="123"/> </appSettings> </configuration> 在我的主程序(“演示”)中,我要添加以下代码: class Program {

在我的主项目(“演示”)中,我添加了对某个项目(“通用”)的项目引用。 在“Common”项目中,我有app.config文件,其中包含:

<configuration>
    <appSettings>
        <add key="test" value="123"/>
    </appSettings>
</configuration>
在我的主程序(“演示”)中,我要添加以下代码:

class Program
{
    static void Main(string[] args)
    {
        Class1 c = new Class1();
        Console.WriteLine(c.Get());
        Console.ReadLine();
    }
}
由于app.config在顶层配置的模型上运行,因此它无法工作

我记得在过去,我在demo项目中添加了一个带有configsection节点的app.config文件。但是我现在有一个问题要做——忘了怎么做

有人能告诉我演示的app.config应该是什么样子吗


谢谢你

App.Config和Web.Config总是从man可执行项目中读取。i、 e.您需要将Common\app.config添加/合并到您的主\app.config

我对您的要求感到困惑。您只想从同一项目中的app.settings读取密钥“test”吗?
class Program
{
    static void Main(string[] args)
    {
        Class1 c = new Class1();
        Console.WriteLine(c.Get());
        Console.ReadLine();
    }
}