问题描述:

I have an app.config that I am trying to get values out of and I am in a solution that is an executable. I have compared the output config.exe and everything is visible. When I try to set these values, they simply do not show up in the collection.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />

</startup>

<appSettings>

<add key="a" value="b"/>

</appSettings>

</configuration>

I have tried everything that I can think of and have never had this problem before. This is part of a larger solution where I cannot show the real values, but I have tested them in a console project that I created and they show up just fine. I am not sure why they wouldn't show up in this particular solution. Could any third party tools effect this?

I am trying to access them like this:

using System.Configuration;

private readonly string stringToSet;

public TheConstructor()

{

stringToSet = ConfigurationManager.AppSettings[key];

}

UPDATE I just figured out that for some reason, a class library is somehow hijacking my app.config. The solution that I am referencing the app.config thinks that I need my keys from .dll.config. How is this possible? The project that I am using the config is referencing it in the same project, not from a class library. How can this happen?

相关阅读:
Top