Karl Gjertsen

Architect, Developer, Speaker, Bad Golfer,
Raygun brand ambassador and creator of Infiniforms

Redgate Error: remote_data_archive_migration_state

I am a big fan of the suite of tools provided by Redgate, especially the SQL Compare and SQL Data Compare products. What I hadn’t realised is just how reliant I have become on them…Until they stopped working! These tool are used on an almost daily basis to push changes from development databases to SQL Azure. They work so well…

Visual Studio cannot find ‘SignTool.exe’

I had installed Visual Studio 2015 onto a laptop and tried to run an application the I had downloaded from TFS. When I pressed F5, I got the error message: Visual Studio cannot find ‘SignTool.exe’ After a little investigation, I found this is part of the ClickOnce Publishing Tools. The Visual Studio installation was run as a default installation and the ClickOnce…

Split web.config into multiple files

Having used web.config and app.config files for many years, today I learnt something new about them. You can split them into multiple files! This can be especially handy if your configuration files are getting too big. Splitting them is very straight forward and I will show you how to move your connection strings into a new file. Step #1: The first thing…

C#: Adding Shorts

Have you ever tried adding 2 shorts together? Did you know that a = a + b and a += b are different? I didn’t! A short is an alias of Int16, or a number that fits into 16 bits. This is half the size of an integer, which is an alias for Int32. short.MinValue = -32768 short.MaxValue = 32767…

String Interpolation in C# 6

Unlike some of the previous releases C# 6.0 isn’t a radical change from the current version of C#. But, it may still change the way you write code. A great example of this is String Interpolation. We originally started concatenating strings using the plus symbol: var myClass = new MyClass(); var fullName = “Full name: ” + myClass.FirstName + myClass.LastName; We then moved on to using String.Format: var myClass = new MyClass(); var fullName = String.Format(“full name: {0} {1}”, myClass.FirstName, myClass.LastName); Now, C# 6.0 gives us…

nHibernate: Flush vs Commit

Whilst working on a legacy project, I had to look at an issue with using nHibernate and ran into the Flush method. As I was new to nHibernate, I had to investigate what this did! using (var transaction = session.BeginTransaction()) {     session.Save(entity);     session.Flush();     transaction.Commit(); } Calling Flush on the Session synchronises the data in the session with the data in the database. Using Flush():…

C#: When to use String vs string

This seems to be a common question from people who are new to programming in C#. The answer is that it doesn’t matter which you use as string is an alias for System.String. However, the convention is to use ‘string’ when you are referring to an object and ‘String’ when you are referring specifically to the string class. Example of…

Unit testing internal methods

TDD means that we do not write any code without a test, then we move code into internal, private or protected methods as we refactor. But what if we are writing a method that is to be used by other developers in our development team and it is meant to be an internal class? What happens if we are not…

Saving an email to SQL Server with Mail4Net

There are a number of reasons why you might want to save your email to a SQL Server database. Maybe you want to be able to resend the message if it doesn’t arrive. A common reason is to have the sending process performed by a dedicated service, such as MailSender, which will soon be available to download from the Mail4Net…

Inversion of control in Mail4Net

Inversion of Control All of the Mail4Net client classes implement a common interface, ISmtpClient. This allows you to use the inversion of control pattern with the Mail4Net clients. To demonstrate using IoC with Mail4Net, I have created a sample class called MailCreator class, which has a SendEmail method that takes an email address and then sends an email to that…