How to create a new Outlook 2013 Email using C# in 3 simple steps

14 December, 2013.

It has traditionally been quite painful to interact with any part of the Microsoft Office product family from a C# application, but thanks to the introduction of dynamics and optional parameters over recent years, the process has dramatically improved. Step 1 - Prerequisites and Assembly References Before doing anything, it is important to note that you must have Microsoft Office 2013 installed for this to work. Seems obvious, but, its still worth mentioning. You also need two references; The…

Continue reading

In the spotlight - Demystifying IQueryable (Entity Framework 6)

24 November, 2013.

I’m not afraid to admit it. I can’t be the only one who has been confused by IQueryable when working with Entity Framework or LINQ to SQL. When using the web to research the topic, I have seen many conflicting blog posts and contradicting answers on StackOverflow. I have read various posts on MSDN about the subject, and I find them difficult to understand and incomplete. I seek to at least attempt to clarify the subject a little with this post. Entity Framework has become such a powerful object…

Continue reading

Exploring logging in Entity Framework 6

13 November, 2013.

A project I am working on at the minute was recently upgraded to use Entity Framework 6.0.1. There were many reasons why we wanted to do this, but one of the most compelling reasons was the new logging (SQL Interception) functionality that ships out of the box. A colleague demonstrated this new functionality and I immediately noticed a problem (limitation if you will) that I foresaw becoming a bigger issue when the time comes to performance tune the application. Implementing simple logging Take…

Continue reading

How to pass Microsoft Exam 70-480 (HTML 5, CSS3 and JavaScript) in 30 days

20 September, 2013.

Before you continue reading this blog, you need to be aware of the following; This is not a “quick fix” or an “easy solution”. I have not discovered some secret formula to guarantee you pass with 100% marks every time. I am not trying to sell you anything. The exam is genuinely challenging and the only way you are going to pass is by working hard! You will not find any brain dumps here! If you’re afraid of working hard to achieve your goals, you best leave now … Still Here? Congratulations, you…

Continue reading

Effectively debugging WPF MVVM applications

13 September, 2013.

Being able to effectively debug any application is key to the success of an application. Every developer, no matter how good they are or how long they have been writing code, introduces bugs. Debugging is the process of identifying bugs and removing them. WPF applications can be particularly hard to debug, if you are not using the correct tools. This post attempts to help you utilise various free tools to help simplify the debugging process. Binding Errors Binding errors are very common in all…

Continue reading

How to fix 'Project failed to build' error when adding an Entity Framework migration (add-migration)

06 September, 2013.

I recently spent several hours tearing my hair out try to figure out why Entity Framework was preventing me from adding a migration to my project. I made some very simple changes to my existing model (I’m developing using the Entity Framework Code First approach) and when trying to add a migration, I was presented with the following error message; But how can this be? For you see, my project does build… My project not only builds, but it runs and works just fine … (up until the point where…

Continue reading

C# Writing unit tests with NUnit and Moq

30 August, 2013.

I’m assuming that you have seen the light, and that you are sold on the benefits (and indeed the drawbacks) of unit testing. I have read literally dozens of blog posts, watched many videos, and read several books about unit testing and the various approaches and frameworks. I have worked with several of these frameworks in both small and enterprise level applications, and I have found that (in my opinion at least) NUnit and Moq are great for helping to get simple tests written quickly and to a…

Continue reading

How to write more efficient and maintainable C# code

23 August, 2013.

When you are writing your C# applications, you are aware that you want to make your applications as efficient, maintainable, and as scalable as possible. These are some great keywords that look great on blog posts like this, but how do you actually set about achieving this goal? We will look at some simply guidelines which try to make this goal more achievable. Write single purpose methods Your methods should have a single purpose… a single task to perform. For example, a single method should…

Continue reading

WPF Entity Framework Code First migrations

16 August, 2013.

Recently I wrote a WPF application using Entity Framework Code First and released it into the wild. Shortly after, the business requirements changed and I had to make changes to the model. Thus, I was introduced to Code First migrations. I did a lot of research on Code First migrations and could only really find the most simple of examples, and almost robotic documentation on MSDN that provided minimal help. This post aims to provide a clearer view on migrations, and how to properly create them…

Continue reading