How To Kill A Process

Do you need to kill (stop) a process running on Windows?

Don’t Show Exception Message To Users

Today, I went to a web site to enter time for a contract I'm working on and I got this:         Never, ever, ever display messages like this to your users. Number one it makes no sense to them. Number two it could reveal some information that could be used to hack … Continue reading Don’t Show Exception Message To Users

Formatting LINQ Statements

Language-Integrated Query (LINQ) was introduced in Visual Studio 2008/ .NET 3.5 and was actually one of my favorite features. It makes writing queries so much easier, especially for XML and object collections. Even though Visual Studio 2013 auto-formats the queries better, there is even an even better way to make them more readable. Here is … Continue reading Formatting LINQ Statements

Updating Bound Controls in an UpdatePanel

Do you need to update a bound control like a GridView or Repeater that is contained in an AJAX UpdatePanel after data is updated? Well there is a trick to it that you need to remember. You would think this should work: Code: //Update some data missingVideosUpdatePanel.Update(); Shouldn't calling the UpdatePanel.Update() cause the control to … Continue reading Updating Bound Controls in an UpdatePanel

Make Disposing Objects Easier

As I talked about in my What’s the Purpose of the “using” Statement? post, disposing of your objects is very important in your application to prevent issues like virtual memory leaks. Equally important is as a developer of a type (class) that use any types that implements IDisposable, then your type must also implement IDisposable. … Continue reading Make Disposing Objects Easier

What’s the Purpose of the “using” Statement?

I recently was asked by one of my clients "What’s the Purpose of the “using statements”? " The developer that asked me this title is Senior Engineer. He went on to state "Looking at the <SOME OTHER> project, I see they didn’t use “using”". When a senior developer actually asks me this I cringe. What I mean … Continue reading What’s the Purpose of the “using” Statement?

Retrieving Application Settings

Here is a safe, generic way to retrieve application settings. public static T GetAppSetting<T>(string key) { if (ConfigurationManager.AppSettings.AllKeys.Contains(key)) {    return (T)System.Convert.ChangeType(ConfigurationManager.AppSettings[key], typeof(T), CultureInfo.InvariantCulture);    }    else    {    return default(T);    } } Usage int serverPort = GetAppSetting<int>("server_port");

Defensive Programming – Verifying Enum Values

One thing I see programmers overlook all the time in their coding is that a valid enumeration value was passed into a method or property. For example, I did an analysis on a 30 project solution that has over 83K lines of code and only once was the enum value verified! As I tell programmers … Continue reading Defensive Programming – Verifying Enum Values

Retrieving Common Windows Paths

Someone asked me recently how to find the path to where Windows is installed. Well it's pretty easy using the code below: var path = Environment.GetFolderPath(Environment.SpecialFolder.Windows); Turns out there is a wealth of path information using the Environment.Special folder enumuration. Here is the output from my XP development machine: Desktop - C:\Documents and Settings\dotNetDave\Desktop Programs … Continue reading Retrieving Common Windows Paths

Web Projects Can Have Version Numbers Too!

When you create a web project with Visual Studio, you might notice that it does not create an AssemblyInfo file for you. I'm not really sure why, but what if you want to give your site a version number like any other .NET project? Well you can... just have to create one manually. Simple create … Continue reading Web Projects Can Have Version Numbers Too!