April, 2013

Debugging Serialization Exception: The constructor to deserialize an object was not found.

Today I was debugging an exception that was occuring when remoting a data object between two .NET processes. I kept getting

System.Runtime.Serialization.SerializationException: The constructor to deserialize an object of type 'com.TheSilentGroup.Fluorine.ASObject' was not found.

The issue I had was that there was a .NET object that looked like this

public class ItemDto{
  public object Item { get;set; }

Which was used as a covariant store for any item (because everything is an object). This was needed because the code I was working in leveraged reflection to pull out certain fields at runtime depending on whatever this object type really was.

But, at some point the ItemDto object was sent to an ActionScript frontend. Later, the same object came back to .NET and the property Item was now a ASObject type due to Fluorine‘s serialization process. Next, this object had to be serialized to another .NET process, and … Read more


Separation of concerns in node.js

I’ve been playing with typescript and node.js and I wanted to talk a little about how I’ve broken up my app source. It’s always good to modularize an application into smaller bits, and while node lets you do a lot, quickly, with just a little bit of code, as your application grows you really can’t put all your logic in one big app.ts.


Instead of the normal application example you see for node projects, I wanted to make it clearer what the initialization of my application does. My app start is structured like this:

* Module dependencies.

import db = module("./storage/storageContainer");
import auth = module("./auth/oauthDefinitions");
import requestBase = module("./routes/requestBase");

var express = require(‘express’)
, routes = require(‘./routes’)
, http = require(‘http’)
, path = require(‘path’)
, log = require("./utils/log.js")
, fs = require(‘fs’)
, passport = require(‘passport’);

var app = express();

class AppEntry{
this.initDb();… Read more


Images, memory leaks, GDI+, and the aggregate function

I ran into a neat C# memory leak today that I wanted to share. It’s not often you get a clear undeniable leak in C# and so I really had fun figuring this one out.

Look at this and see if you can spot the leak:

public static class Extensions
    public static Image Append(this Image source, Image append)
        var newImage = new Bitmap(source.Width + append.Width, source.Height);
        using (var g = Graphics.FromImage(newImage))
            g.DrawImage(source, 0, 0);

            g.DrawImage(append, source.Width, 0);

        return newImage;

private static void Main(string[] args)
    var src = @"C:\users\anton\desktop\bigImage.jpg";

    var images = Enumerable.Repeat(Image.FromFile(src), 25).ToList();

    var appendedImage = images.Aggregate((acc, i) => acc.Append(i));

    foreach (var image in images)



What this code does is create 25 instances of my bigImage.jpg (6.5MB), and then creates a new image consisting of those 25 images side by side. The aggregate function folds the list … Read more

, ,

A response to “Ten reasons to not use a functional programming language”

If you haven’t read the top ten reasons to not use a functional programming language, I think you should. It’s a well written post and ironically debunks a lot of the major trepidations people have with functional languages.

But, I wanted to play devils advocate here. I read a lot of articles on functional and everyone touts a lot of the same reasons to use functional languages, and this post was no different. What these posts always lack, though, is acknowledgement that functional isn’t the end all be all of language solutions. It has plenty of problems itself, and it’s just as easy to critique it using the same ten reasons. That said, I wanted to address a few of my opinions regarding functional programming using the same format as the original article.

Reason 1: I don’t want to follow the latest fad

The authors point here is that … Read more


Tech Talk: Text Editors

Today’s tech talk was a little less tech but no less important. We got together and talked about the different text editors that we use and why we like them.

JuJu Edit

  • Pros: We use JuJu at work a lot because it handles enormous files really well. And when I mean enormous I mean upwards of 50+GB log files. Other editors choke when its this big but JuJu handles it fine. On top of that JuJu lets you do custom syntax highlighting, which is great for log files, since now you can highlight Debug, Warn, Info, Errors, etc. It’s pretty bare bones but its very lightweight and useful for quick note taking and basic text editing. Also having the ability to auto reload the file on changes makes it great as a tail replacement.
  • Cons: JuJu isn’t in active development anymore and the documentation is non-existant (setting up the regex
Read more


Command pattern with SignalR

I’m using SignalR as a long poll mechanism between multiple .NET clients because part of my projects requirements is to have everything over http/https. There’s no point in rolling my own socket based long poll since SignalR has already done all the heavy lifting. Unfortunately since the app I work on is distributed I can’t upgrade my SignalR version from what I have (0.5.2) since the newer SignalR versions aren’t backwards compatabile. This means I have to make do with what this version of SignalR gives me.

Still, the version I have works great for my purposes and I can’t complain. However, I was getting frustrated at having to constantly update my internal boilerplate whenever I wanted to add a new hub method dispatch. What I want is to have a single method dispatch and encapsulate all my business logic in a command pattern so that I never have to … Read more

, ,

Jon Skeet, C#, and Resharper

Today, at 1pm EST, the venerable Jon Skeet had a goto meeting webinar sponsored by JetBrains reviewing weird and cool stuff about C# and Resharper. For those who aren’t in the know, Resharper is a static analysis tool for C# that is pretty much the best thing ever. Skeet’s a great speaker and my entire team at work and I watched the webinar in our conference room while eating lunch.

I took some notes and wanted to share some of the interesting things that Jon mentioned. You can watch the video here. It’s an hour long and definitely worth viewing.

Recursive Parameterization

Skeet talked about how Resharper, and in fact the C# compiler lets you do weird stuff like this:

public class SuperContainer<T>

public class Container<T> : SuperContainer<Container<Container<T>>>

Even though this leads itself to recursive parameterization. Compiling this is just fine though. However, even if … Read more


Capturing mutables in f#

I was talking about F# with a coworker recently and we were discussing the merits of a stateless system. Both of us really like the enforcement of having to inject state, and when necessary, returning a new modified copy of state. Functional languages want you to work with this pattern, but like with all things software, it’s good to be able to break the rules. This is one of the things I like about F#, you can create mutables and do work imperatively if you need to.

But, there is a small caveat with mutables: you can’t close over them. Look at the following example:

let g() = 
    let mutable f = 0;
    fun () -> Console.WriteLine f

The intent is that calling g() would give you a new function that writes f to the console. In C# it would be the same as

public Action g(){
    int f = 
Read more

, , ,

Tech talk: Hacking droid

Todays tech talk was based off of a blog entry posted by facebook recently where they described the things they needed to do to get their mobile app running on android OS Froyo (v 2.2).

The gist of the post was that facebook migrated a lot of javascript code to Java and then found themselves in an interesting situation: they were unable to load the app due to the number of methods declared being larger than the method metadata buffer could hold. The buffer, called “LinearAlloc”, on this particular droid version was 5MB in size. Later versions were increased to 8MB which meant that the bug was no longer exhibited.

Facebook’s engineers tried to break their application up into multiple droid executable files (dex), tried automatic source transformations to minimize their method calls, tried refactoring some of their code (but were unable to make siginifant headway due to the strong … Read more


Advice to young engineers

I had the opportunity to represent the company I work for at an engineering networking event at the University of Maryland today catered to young engineering students of all disciplines. The basic idea was to be available for students to ask questions they don’t normally get to ask of working professionals such as “what’s the day to day like?” [lots of coffee, followed by coding all day], “what advice would you give to someone looking to get into xyz field”, etc.

Personally I had a great time being there since as an alum I felt like I could relate to their specific college experience. In this post, I wanted to share a couple of the main points that came up today during my informal discussions with the students.

Don’t be afraid of problems

I really wanted to stress this to the people I talked to today. You can’t … Read more


Previous Posts