Grow Your Own SyncRoot

3 Comments »

Multi-threaded code is challenging to get right and even harder to debug once it’s gone wrong. This is especially true when attempting to collect data from multiple threads. To make this easier, many .NET collection classes include the SyncRoot property to maintain proper synchronization with other threads that might be simultaneously modifying the collection. But then Microsoft changed its mind in .NET 2.0 and decided to let the developer decide how to manage synchronization, and so none of the new generic collections have a SyncRoot property.

Read the rest of this entry »

NotifyIcon.ShowBalloonTip Issues

13 Comments »

NotifyIcon is .NET’s version of the system tray icon, those little icons that appear next to the clock in the Windows Start bar.  .NET 2.0 added the ability to display a pop-up balloon tip pointing at a tray icon.  However, this capability doesn’t always work as you would expect.

Read the rest of this entry »

.NET Installers

5 Comments »

Most computer software is delivered in a compressed form for sale and distribution.  This “setup program” is typically an executable that unpacks the software and installs it correctly on the computer, taking into account variations between computers and customized user settings. 

The software that produces these setup programs is called an “installer.”  Installers are typically one of the most expensive tools a developer will buy, though of course there are free and open source installers available.

Following is a list of installers available today for .NET software and any online reviews.  Price is for one developer license unless otherwise noted.  A plus sign indicates the price is for the standard version, and advanced versions are available.  Please comment if any installers are missing, or if you would like to report any new reviews, updates, errors or broken links, as I will keep this list updated.

Read the rest of this entry »

See All Key Events with KeyPreview

4 Comments »

Handling keyboard shortcuts in your application can sometimes get a bit tricky.  Consider the standard Ctrl+C shortcut, which every application should support as a “Copy” to clipboard command.  When you users type in textboxes in your application’s form, they will expect that Ctrl+C will copy the selected text.  But this feature is not supported by default; you have to explicitly write some code.

Read the rest of this entry »

.NET Obfuscators

33 Comments »

Obfuscation is the process of scrambling and encrypting software so that it cannot be easily reverse-engineered.  The goal is to stop all casual hackers and as many serious hackers as possible from trying inspect and crack the code.

As I described in my article "Obfuscation? Gesundheit!," programs written for .NET can be reverse-engineered quite easily.  Anyone with a decompiler such as the free .NET Reflector can look at .NET applications and libraries and literally see the entire original source code, including names, logic and flow.  Hackers can inspect .NET software to find and exploit its security flaws, steal unique ideas and license keys, or pirate the application.  To plug this massive security hole, .NET software should be obfuscated.

Following is a list of .NET obfuscators available today and any online reviews.  Price is for one developer license unless otherwise noted.  A plus sign indicates the price is for the standard version, and advanced versions are available.  Please comment if any obfuscators are missing, or if you would like to report any new reviews, updates, errors or broken links, as I will keep this list updated.

Read the rest of this entry »

Enter Key in DataGridView

16 Comments »

The DataGridView is a terrific control built into .NET that provides a customizable table for entering and displaying data. If you provide the DataGridView in your software as a means for the user to enter multiple rows of data, you may wish to redefine the default behavior of the Enter key. Read the rest of this entry »

Remove Whitespace from C# Strings

37 Comments »

You probably knew that you can use the String.Trim method to remove whitespace from the start and end of a C# string.  Unfortunately, the Trim method does not remove whitespace from the middle of a string.

Read the rest of this entry »

Format String for XML Value

3 Comments »

Of course you know that XML denotes element names with greater-than and less-than symbols, such as:

<name>value</name>

Therefore, to avoid confusing the XML parser, the greater/less symbols (and the ampersand, an HTML special character) must be encoded.

Read the rest of this entry »