title: I get errors when viewing forms in the designer - how can i avoid this?
body: <p>Some of my forms show errors when i load them in the designer. This is because in their constructors they use system settings loaded from a configuration file. When the form is loaded in the designer it uses some random path and unsurprisingly the config file isn't there. </p>
  
  <p>eg. 
  The configuration file C:\Documents and Settings\Rory\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies\it3dtcgg01\PrioryShared.dll.config could not be found. </p>
  
  <p>Is there some way I can deal with this so that the form displays correctly in the designer? 
  eg: </p>
  
  <pre><code>if (!inDesignerMode) 
  { 
      loadSettingsFromConfigFile();
  }
  </code></pre>
  
  <p>UPDATE: 
  ok, I'm still getting this error. The composition is like this </p>
  
  <ul>
  <li><p>MyForm.cs</p>
  
  <ul>
  <li>MyCustomControl.cs</li>
  </ul></li>
  </ul>
  
  <p>In MyCustomControl's constructor I've put </p>
  
  <pre><code>if (!this.DesignMode)
  {
      // Get settings from config file   &lt;- this is where the error occurs
  }
  </code></pre>
  
  <p>but it's on that line that I still get the error in the designer. What gives?</p>
  
  <p>UPDATE: Worth noting <a href="http://msdn.microsoft.com/en-us/library/ms996457.aspx#" rel="nofollow noreferrer">this link</a> that describes how to debug design-time controls.</p>
  
  <p>UPDATE: Control.DesignMode isn't set to true when called within the constructor (<a href="http://msdn.microsoft.com/en-us/library/ms996457.aspx" rel="nofollow noreferrer">MSDN</a>) of the object! So that sort of code should go in the onLoad. Alternatively you can use an approach like <a href="http://devlicious.com/blogs/derik_whittaker/archive/2006/09/25/Determining-if-the-.Net-IDE-is-in-Design-Mode.aspx" rel="nofollow noreferrer">this</a></p>