ESMITHY.NET

Silverlight Localization

The official Silverlight documentation about localization gives lots of information about working with resource files, but it is kind of scant on how to actually get localized strings to show up in the UI in a reasonable way. For example, an unreasonable way would be to set the text/content …

Unit Testing Silverlight View Models

Being relatively new to Silverlight development, I've not had the good sense to accept conventional wisdom that the Visual Studio unit test framework can't be used to test Silverlight code. For testing view models at least, I've been successfully using Mstest and Rhino Mocks for a few months now.

One …

Guidelines for Method Parameter and Return Types

I've been reading Jeffrey Richter's CLR via C# lately, and just read a section titled "Declaring a Method's Parameter Types". That title doesn't exactly promise a riveting read, but it did a nice job of articulating some guidelines for method parameter and return types, independent of any particular programming language …

Converting from Visual Studio 2005 to Visual Studio 2008

I've just finished switching over our development environment from Visual Studio 2005 to Visual Studio 2008 (except for a C++ solution that uses boost, which will take some further effort). These are the things that I needed to do, and the gotchas I encountered.

  1. Getting installed - Aside from being a …

Getting the Host's Main Window Handle in an Office Add-in

Sometimes you want the window handle of the host application when you're writing an Office add-in. Excel includes that as a property of the Application object in newer versions of the object model, but Word and PowerPoint don't. I seem to remember some sample code from Microsoft that suggests using …

Paste Special Macro for Word

I sometimes wonder how often the default paste operation in an application is appropriate. Maybe I'm abnormal (maybe?) but it seems like 73.2% of the time, I want pasted text to match the formatting of where it is going rather than where it came from. I guess the exception …

.NET BackgroundWorker Summary

The System.ComponentModel.BackgroundWorker class makes it easy to code a long running operation with the ability to provide progress, cancellation, and notification of completion. It is particularly nice for UI because while the long running operation executes on a thread pool thread, notifications of progress and completion are marshalled …

Temporary CommandBar Customizations in Word

It's common for an Office add-in to put some custom menu items or toolbar buttons in the UI of the hosting application. The method to call to do this is CommandBars.Add. It is also typical that you'd like those customizations to appear so long as the add-in gets loaded …

Sleep Mode from .NET

I have a little backup program that I wrote that includes the ability to shut down the machine when a backup is complete. I wanted to add the option of putting the machine to sleep instead of shutting down, but it took me a while to figure out how to …

Finding Unmanaged Memory Leaks

At work we had a long-running .NET process whose memory usage seemed to be going up, but not coming down. In investigating, I learned a few things about leak hunting, and ultimately tracked down perhaps the most insidious leak I've ever seen.

My first approach was to try to profile …