Debugging windows services

One problem that I have ran into time and time again while working on windows services is the difficulty around needing to debug them.  Sure, you can setup the service within windows and then start it up and try to attach the debugger before your problem area hits.

But there is a better way. Continue reading


Moq and entity

So this week while trying to implement a repository pattern within a MVC Web API project I found myself writing unit tests to verify that the response is what we would expect.  As part of this, the entity query was using the DbFunctions.AddDays method.  When you mock the backing DBSet collections, the code does not know what to do with these DbFunctions and will throw an error. Continue reading

JSON standards vs C# naming standards

Anyone that has coded in C# for any amount of time is accustom to seeing property names in Pascal case such as the example below…

public class MyClass {
    public string MyString { get;set; }
    public int MyInt { get;set; }

Which will serialize the class as follows…

{ "MyString":"hello world","MyInt":1 }

Some of your JSON gurus would tell you that the properties for a JSON object should really be in camel case instead of pascal (examples). So we are in-between worlds here trying to find something that will work for everyone.

Our first option would be to use the JsonPropertyAttribute to specify the name for the property during serialization such as below…

public class MyClass {
    public string MyString { get;set;}
    public int MyInt { get;set; }

Option two would be to make a change in the serialization options such as below…

    MyClass obj = new MyClass()
        MyInt = 1,
        MyString = "hello world";
    var jsonSettings = new JsonSerializerSettings
        ContractResolver = new CamelCasePropertyNamesContractResolver()
    string json = JsonConvert.SerializeObject(obj, Formatting.Indented, jsonSettings);

Both of which will give us our desired output of…

  "myString": "hello world",
  "myInt": 1

This may be most useful when working within the WebAPI technology of If you would like to set the serializer to camelcase for the entire api, you would would need to add the below line to your Application_Start() method within your global.asax

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

Hiking Giant City

A few weeks back we took a stay-cation and visited someplace that is somewhat close to home.  During our stay we decided to take the kids south to Giant City State Park in Illinois to hike some of the many trails and introduce them to hiking through the woods.

When we arrived we started at the visitor’s center and got some information about the park and also viewed some of the displays about some of many species in the park.  This was a lot of fun actually because the kids were very interested to my surprise in what the animals are, where the trails went in the park, and genuinely enjoyed looking and playing with the different things.  After this we went and climbed the water tower to look out over the park.  I have to admit I was not a fan of the heights after we started, but pulled through for the kids and got to the top to look around. Continue reading

In the waves of change

Over a year ago I started at a new company after working for the same employer for a very long time.  Before I started I had already heard about the culture and environment in which I was about to join.  I could hardly wait.  Soon after I had started I quickly seen the creator of that culture.  The COO was a strong leader that was also one of the most approachable people within the company.  She recognized a company is only as good as its people and cultivated a great work force.  She provided great leadership but also took the time to do the little things that matter.  Whether it was hand delivering the paychecks to over 400+ employees (and she knew everyone’s name and families to boot), or the yearly lunch with her on your anniversary; she took the time.  She was able to relate to the people working for the company and because of that she will always have their respect.

Change is constantly happening around us and today is no different.  The only thing that is predictable is that it will happen.  Today I got the pleasure of saying goodbye to this fine leader that I respect so much.  She is leaving the company for what I can only hope is greener pastures.  She was the face of the company in more ways then I think many realize and she will be sorely missed.  She has won my respect and as I grow in my career and leadership aptitude, I can only strive to one day earn the respect that she clearly had from my coworkers and myself.