DarthFubuMVC/fubumvc — Issue #186: AppSettingsProvider 
Author: KevM
Created: 2011-11-10 20:41:19+00:00
State: open

Started a fresh web application. Pulled FubuMVC in via Nuget.

Setup the container as follows

```cs
var container = new Container(cfg=>
{
cfg.Scan(s=>
{
s.TheCallingAssembly();
s.Convention();
});

cfg.For().Use();
});
```

Created a settings class

```cs
public class SimpleSettings
{
public string Name { get; set; }
}
```

Taking a dependence on SimpleSettings throws this exception:

```
Applying extension FubuMVC.GettingStarted.GettingStartedExtension
Applying extension FubuMVC.Diagnostics.Core.AdvancedDiagnosticsFubuExtension
Applying extension FubuMVC.Diagnostics.AdvancedDiagnosticsRegistry
Applying extension FubuMVC.Spark.SparkEngine
StructureMap.StructureMapException: StructureMap Exception Code: 207
Internal exception while creating Instance '2706e65f-37d8-4860-9e56-61f6e0d29c4f' of PluginType Admin.Clarify.DovetailDatabaseSettings, Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Check the inner exception for more details. ---> System.TypeInitializationException: The type initializer for 'FubuCore.Configuration.AppSettingsRequestData' threw an exception. ---> System.ArgumentException: exePath must be specified when not running inside a stand alone exe.
at System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath)
at System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel userLevel)
at FubuCore.Configuration.AppSettingsRequestData..cctor() in c:\BuildAgent\work\1597e8b85844e527\src\FubuCore\Configuration\AppSettingsRequestData.cs:line 16
--- End of inner exception stack trace ---
at FubuCore.Configuration.AppSettingsRequestData..ctor()
at FubuCore.Configuration.AppSettingsProvider.SettingsFor(Type settingsType) in c:\BuildAgent\work\1597e8b85844e527\src\FubuCore\Configuration\AppSettingsProvider.cs:line 29
at FubuMVC.StructureMap.SettingsScanner.<>c__DisplayClass1.b__0(IContext c) in c:\BuildAgent\work\e5cfff0cc125d023\src\FubuMVC.StructureMap\SettingsScanner.cs:line 15
```

The relevant bit being:

>The type initializer for 'FubuCore.Configuration.AppSettingsRequestData' threw an exception. ---> System.ArgumentException: exePath must be specified when not running inside a stand alone exe.

It seems that in the executing context the app settings provider cannot initialize statics because the SystemConfiguration at that moment cannot find the application configuration config file. This seems like it might be a bottles thing. Not sure how to reproduce it in that project.