Exception when installing Visual Studio 2012 Update 3

When I try to install Visual Studio 2012 Update 3, the installer immediately crashes:


Looking at the Log File that was created, I can see it’s related to Fonts:

[14D8:1218][2013-06-27T02:40:58]: MUX:  Exception: Info: InnerException: Info:
[14D8:1218][2013-06-27T02:40:58]: MUX:  ERROR: Not a valid Win32 FileTime.
Parameter name: fileTime
[14D8:1218][2013-06-27T02:40:58]: MUX:  Stack:    at System.DateTime.FromFileTimeUtc(Int64 fileTime)
   at System.IO.File.GetLastWriteTimeUtc(String path)
   at System.IO.Directory.GetLastWriteTimeUtc(String path)
   at MS.Internal.FontCache.FontSource.GetLastWriteTimeUtc()
   at MS.Internal.FontCache.FamilyCollection.AddPhysicalFamilyToList(FontSource fontSource, List`1 familyList, SortedDictionary`2 familyNameList, SortedList`2 frequentStrings)
   at MS.Internal.FontCache.FamilyCollection.BuildFamilyList(List`1& familyList, SortedDictionary`2& familyNameList, SortedList`2& frequentStrings)
   at MS.Internal.FontCache.FamilyCollection.MS.Internal.FontCache.IFontCacheElement.AddToCache(CheckedPointer newPointer, ElementCacher cacher)
   at MS.Internal.FontCache.HashTable.Lookup(IFontCacheElement e, Boolean add)
   at MS.Internal.FontCache.CacheManager.Lookup(IFontCacheElement e)
   at System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
   at System.Windows.Media.FontFamily..cctor()

So one of my fonts is crashing for whatever reason. I wrote a small console app to find out which font:

void Main()
    string str = Environment.GetEnvironmentVariable("windir") + @"\Fonts\";
    var _windowsFontsLocalPath = str.ToUpperInvariant();

    using(var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts")){
        foreach(var value in key.GetValueNames()){
            var name = key.GetValue(value) as string;
            var fullName = name.Contains("\\") ? name : Path.Combine(_windowsFontsLocalPath, name);
                Console.WriteLine("Font doesn't exist: {0}", fullName);

            try {
            } catch (Exception ex){
                Console.WriteLine("Exception accessing {0}: [{1}] {2}", fullName, ex.GetType().Name, ex.Message);

The output showed a broken font:

Exception accessing C:\WINDOWS\FONTS\Exo-Thin.otf: [ArgumentOutOfRangeException] Not a valid Win32 FileTime.

C:\Windows\Fonts>dir exo-thin.otf
  Directory of C:\Windows\Fonts

02/05/22705  11:03 AM           104,912 Exo-Thin.otf

So apparently I have a font from the future that causes WPF to crash. Why? Not sure, could be an indication of a hard drive crash or some other sort of corruption. I ended up fixing it with a one-liner:

File.SetLastWriteTimeUtc(@"c:\windows\fonts\Exo-Thin.otf", DateTime.UtcNow);

After that change, Visual Studio Update 3 installed without issue.

5 Years of Stackoverflow.com

On April 6, 2008, Jeff Atwood asked for help naming his little project. On April 16, he announced StackOverflow.com. On September 16, it launched. (What’s the obsession with the number 6, Jeff?). In between, beta access was granted to people. I was part of the second beta wave and got my access on August 1, 2008:

Welcome to the Stack Overflow private beta!
Please read this first. Seriously:

The beta site is at:

Login is your email address, and the password is "falkensmaze" without the quotes.


At the time, I was just starting out with C#. I had been a hobby programmer for most of my life, hacking stuff together in BASIC, Pascal/Delphi and PHP for most of my life. I actually graduated as an IT Specialist and was working in customer support in a video game company at the time, so I had no real clue how to properly program. A year earlier, I had picked up C# development because we were implementing a SharePoint 2007 installation and as the programmer in our 3 person team, that role fell to me. My first attempt at ASP.net wasn’t great and I actually felt PHP was superior because it just worked without requiring so much web.config magic and IIS configuration.

StackOverflow was a relief, because all of a sudden I had a good place to ask questions, regardless how simple and stupid. But even more important, StackOverflow is a fantastic place to answer questions. When asking, I was already set in a path of thinking about the problem and was more or less having tunnel vision. When answering, I had to expand my horizon, look up and try out stuff. Yes, even in the early days we had to deal with the fastest gun in the west problem, but early on it was already evident that there is a community of great people there and we all got a lot of knowledge out of it.

It amazes me that now, 5 years later, it is still the only really relevant Q&A site for programmers. I don’t know why, I guess it’s the combination of Jeff Atwood’s celebrity status, the no-bullshit signup and page layout and the fact that it hit the internet at the time Twitter exploded. I follow many people I first “met” on StackOverflow and when 140 chars are too limiting I can open a question on StackOverflow or Programmers.SE. There are many great people who were part of the early pioneering group, including Matt Hamilton, Jin Yang, Konrad Rudolph, John Sheehan and many, many more.

In the past 5 years, I went from being a guy without a programmer title or formal education hacking stuff together through 1 transatlantic relocation and 3 promotions to be a proper software engineer. I still hack stuff together, but now I know why 🙂

My 5 minutes of fame came when I was the first user to hit 10k reputation and I can forever claim that my post housed the very first comment, ever. But to me, StackOverflow was and is more than just a fancy reputation badge.
It was simply one of the best things that ever happened to me and I’m eternally grateful to all the people who made it happen.


I don’t have as much time anymore to have a lot of activity, but I’m still an avid reader (I mainly read through Eric Lippert’s and Jon Skeet’s RSS Activity Feeds. Seriously, if you do .net, subscribe to their feeds right now. “No bullshit” RSS Feeds is another one of these seemingly simple features that sets StackOverflow apart from the rest) and I know that whenever I have a question, I will get a great answer.

Happy birthday, Stack Overflow. Here’s to the next 5!

Are Data Annotations a sign of bad design?

The .net Framework comes with a validation system, called Data Annotations. At first glance, these are pretty awesome and I have used them a lot. In a nutshell, it allows you to do stuff like this:

public string Title { get; set; }

It is also absolutely trivial to write your own validators and to validate objects using these. In fact, ASP.net MVC will automatically verify these as part of its model binding.

However, they have their limits, and because of these limits I started questing them a while ago. Since they are attributes, they have to be constant – not a big deal, constraints should be constant anyway. There is some awkwardness around MVC model binding, for example this:

public byte Value { get; set; }

will actually blow up during model binding if a negative amount is passed since the binding of a negative value to a byte fails and we don’t even get to this point – arguably, this is an ASP.net MVC issue and not directly related to Data Annotations.

The bigger problem with Data Annotations is that they can’t validate the object completely and thus make it hard to adhere to DRY and SRP rules. For example, let’s say I have a business rule that says that Titles must be unique.

Whose job is it to ensure this constraint? With Data Annotations, we put the responsibility in the hands of the business object, which turns it from a simple data structure into an object (Uncle Bob Martin has some good insight about the distinction in his book Clean Code) and thus may violate SRP.

Let’s say we would want to create a [NoDuplicateTitle] Attribute. Inside the attribute, we could use Dependency Injection to get a database connection (since MVC 3, there is a built in DependencyResolver static), then do the validation and bail out if required. Our Business Service and Repository layers could then just run validation on the business object itself to not duplicate their logic.

The obvious problem is that these attributes are not reusable outside of an ASP.net MVC application unless you bundle them with their own Dependency Injection mechanism (essentially just a Service Locator). The other problem is that you just added additional database calls to your application, in places that aren’t immediately obvious.

Another issue I see: What about other dependencies that aren’t directly visible from the database? Let’s say you have a rule that says you can only create 10 items an hour. That rule may change over time (e.g., next week management decides that it should be 25/hour) or may be inconsistent accross users (HR personell can create an unlimited amount while IT staff can only create 5). These rules are not constants, they can change from one second to the other. Also, this rule doesn’t describe the validity of an object but rather the validity of an action. The same object may be valid or invalid depending on the user and time of submission and thus can only reliably be verified in the service in the moment you actually try to save it.

Is it the responsibility of the business object to know if it can be saved given the current user and time? That seems like too much responsibility for something that’s supposed to be a data structure. Is it the services responsibility? That sounds more like it, since ultimately the service enforces the business rule. But if the service enforces the "10 items/hour" rule, shouldn’t it also enforce the "64 character max length" rule? Because if the title is too long, the save should fail. Should the business object care why it fails?

Arguably, the C# type system is causing us some grief here since there is no good way to create a type with constraints like "a number between 0 and 100" or "a non-empty string that is 64 characters or less" (I think that Haskell or F# support this), but we still have to solve it somehow.

One way is to create a IEnumerable<ValidationResult> Validate(MyBusinessObject bo) method in the service and have it make the calls. This satisfies SRP and DRY since it’s now only the service that handles this. The downside is that we lose some cheap and easy ways to build HTML Forms, e.g. an Html.TextBoxFor call can no longer check for a StringLengthAttribute to set the maxlength on the generated textbox. Data Annotations still make sense on View Models given that, but now we violated DRY and have to deal with changes all over the place (someone decides that Titles can be 72 chars long. You now need to change it in all places, and since you’re likely dealing with a hardcoded literal 64 you need to make sure you’re not changing some other constraint that also was 64 and shouldn’t change. If you want to use a public const int MaxTitleLength = 64 you need to ask yourself where to put it. On the service? Now your ViewModels have a compile-time dependency on the service. On the business object? Seems to violate SRP. In a Constants.cs class? Smells like a big ball of mud. It has to go somewhere and the correct answer will vary by project and by the underlying tech stack, but it’s an interesting problem to think about nevertheless.

There is another option involving dynamic generation of attributes at compile time, but that seems like a lot of bandaid. I don’t know what the right answer is, but I’ll try a different approach without Data Annotations for my next project and see how that goes.