title: Settings.Default.<property> always returns default value instead of value in persistant storage (XML file)
body: <p>I recently wrote a DLL in C# (.Net 2.0) which contains a class that requires an IP address. A co-worker of mine altered the class to retrieve the IP from a ".dll.config" (XML) file -- This apparently is automatically generated by the "Application Settings" file he created (Settings1.settings). The benefit of this was to allow the end-user to change the IP address in the XML/config file at will.</p>
  
  <p>Unfortunately, when I check his code out of the tree and try to compile (or use) this new code, any application calling this DLL only gets the default value, rather than the value from the file.</p>
  
  <p>The constructor that calls the config file looks like this:</p>
  
  <pre><code>    public class form : System.Windows.Forms.Form
      {
          public form()
          {
              // This call is required by the Windows Form Designer.
              InitializeComponent();
              IP = IPAddress.Parse(Settings1.Default.IPAddress);
          }
      }
  </code></pre>
  
  <p>I found <a href="http://social.msdn.microsoft.com/Forums/en-US/clr/thread/f3a4b138-6e6c-42e3-86e8-1f86c90f8fb4/" rel="noreferrer">a reference to this problem on the MSDN forums</a> where a user said:</p>
  
  <blockquote>
    <p>the 'old' values (the ones you define at development time) are hard coded. If the franework isn't  able to access or open the config file it will use the defaults instead. This will always happen if you use settings in a dll.</p>
  </blockquote>
  
  <ol>
  <li><p>Does this mean that I cannot store an external value for a DLL in a config file?  (My co-worker has somehow made this work...)</p></li>
  <li><p>Since my framework appears to be unable to access or open the config file, how do I figure out why it's failing? Or even detect when this happens?</p></li>
  </ol>
  
  <p><b>Decker</b>:  That helps a bit. Unfortunately, I am writing this DLL to a specification, so I don't actually have access to the Application's config file. As you'll note above, my co-worker created a "Settings<b>1</b>.settings" file. I didn't understand this at the time, but it seems now that adding the "1" keeps it out of the settings space of any application that calls it. </p>
  
  <p>I guess what I'm trying to figure out is why the DLL doesn't seem to find the config file sitting next to it in the same directory. Tracing thru the code step-by-step reveals nothing.</p>
  
  <p>As an aside, I can change the "Output Type" of my assembly from "Class Library" to "Windows Application" and add the following lines at the beginning of my DLL code:</p>
  
  <pre><code>    [STAThread]
      public static void Main(string[] args)
      {
          System.Windows.Forms.Application.Run(new form());
      }
  </code></pre>
  
  <p>When I run this, it generates a different config file (a ".exe.config") and that one I can alter and have it pull the new data from the file. So I'm a bit confused. Any ideas?</p>