typeinitializer

HttpRuntime..cctor takes forever to execute

Dead simple code: using System; using System.Diagnostics; using System.Web; using System.Web.Caching; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Stopwatch sw = Stopwatch.StartNew(); Cache cache = HttpRuntime.Cache; Console.WriteLine(sw.El...

Try/catch blocks inside constructors

Hi, Is it a bad programming practice to have try/catch blocks inside constructors? Or does it make no difference as long as our programs handle typeinitializer exceptions gracefully. In C# if there are any exceptions inside a constructor the framework always throws typeinitilizer exceptions. Thanks, Shamika ...

Why doesn't the CLR always call value type constructors

Hi, I have a question concerning type constructors within a Value type. This question was inspired by something that Jeffrey Richter wrote in CLR via C# 3rd ed, he says (on page 195 - chapter 8) that you should never actually define a type constructor within a value type as there are times when the CLR will not call it. So, for example...