C# - Re-initialize static class?

  ConstructorInfo constructor = typeof(Settings).GetConstructor(BindingFlags.Static | BindingFlags.NonPublic,null, new Type[0], null);
  constructor.Invoke(null, null);

You could use reflection:

var prop = typeof(Settings).GetField("setting1", BindingFlags.Static | 
                                                 BindingFlags.Public);
prop.SetValue(null, "Bar");
string currentValue = Settings.setting1; //Bar

If the above code is representative of the situation you're in, you won't be able to reinitialize the code unless you do something particularly hacky with reflection (this is not recommended by the way).

Edit: Oh wait - I didn't realize this was a web app. You could programmatically bounce the application:

System.Web.HttpRuntime.UnloadAppDomain

Tags:

C#

Class

Static