Articles in the How-To category

Sleep Mode from .NET

By Eric

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 …

Read more...

Finding Unmanaged Memory Leaks

By Eric — 5 minute read

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 …

Read more...

Generating XML Serialization Assemblies

By Eric — 2 minute read

The .NET XML serialization support is pretty cool -- I've used it for a few projects now. It provides an easy way to convert objects with properties to and from XML. The implementation dynamically generates a serialization assembly to do this at runtime, so a recommended strategy for improving runtime performance …

Read more...

Getting an IStream on a File

By Eric

Getting a COM IStream instance on a normal file seems like something that should be trivial to do, but it always seems to take some hunting to remember how it is actually done.

There is a function in the shell API that will return an IStream on a file: SHCreateStreamOnFile …

Read more...

Remote Debugging

By Eric — 3 minute read

"It works on my machine" is not a very solid defense. And when something baffling is happening in your code on a non-development machine, and logging doesn't give enough clues, it can be a good time to take advantage of remote debugging.

In the past I've equated remote debugging to …

Read more...

File System Monitoring

By Eric — 6 minute read

At times it is useful to keep tabs on what is happening (or has happened) in the file system. This is a brief overview of all the ways I know of to track activity on a Windows file system.

Scanning

Scanning is the brute-force approach to knowing what is happening …

Read more...

XP Common Controls with VC++ 2005

By Eric — 1 minute read

This morning I was asked to enable the Windows XP visual styles for our application. No problem -- I've done that for applications many times. Just drop the appropriate manifest file in the right place, call InitCommonControls and all should be well. When I tried that this morning, though, I got …

Read more...

Ten Lessons Learned Assembling a PC

By Eric — 10 minute read

I spent some of my Christmas vacation upgrading the hardware on my PC. I've been suspicious that there was something wrong with my old motherboard, so I decided to get a new one. And when you're getting a new motherboard, you might as well get a new CPU and new …

Read more...

.NET Context Menu Handler

By Eric — 3 minute read

I've been working on a context menu handler shell extension in C# lately. There are a few samples that people have produced on the web (for example, The Code Project, pek.com, and TheServerSide.net). I've found a better way of implementing IShellExtInit.Initialize than in the examples I've seen …

Read more...

Techniques for Effective Logging

By Eric — 6 minute read

Updated September 8, 2005

Logging is a testing and diagnostic technique that lies somewhere between automated testing and debugging. It can help you understand what your application is doing, especially in cases where there is some non-determinism because of threading, or when running in an environment where debuggers are not …

Read more...