A Day in the Life

A day in my life. Thoughts on leadership, management, startups, technology, software, concurrent development, etc... Basically the stuff I think about from 10am to 6pm.

12/17/2007

VS2005 C++ Build Error vc80.pdb

Are you getting the errors:

Could not delete file ‘c:\myproject\obj\release\vc80.pdb
Make sure that the file is not open by another process and is not write-protected.
Could not delete file ‘c:\myproject\obj\release\vc80.idb
Make sure that the file is not open by another process and is not write-protected.

Then maybe you have the problem described here.

Another solution is to change the number of processes you allow the build process to use.

1. From the VS2005 IDE menu bar select: Tools.Options.Projects and Solutions.Build and Run.
2. On the Build and Run page set the "maximum number of parallel project builds" to 1.

Problem solved.

12/13/2007

AVIFileOpen returns 0x8004406d…

So what does it mean? I was trying to open a .wav file to merge into my AVI stream. After a bit of running around I found that my .wav file only contained a header…no data. And this is why the AVIFileOpen was failing with the return code AVIERR_FILEREAD.

Not a very good error message because the Microsoft documentation says the error indicates, "A disk error occurred while reading the file."

Which is not the case.

10/24/2007

Out and About – Oct 28th, Silicon Valley Code Camp

I'm giving two talks again this year at the Silicon Valley Code Camp. The first talk is at 9:15am and called "Architecture- Building Commercial Apps for Success". I'm going to talk about the things I've learned over the last 20 years delivering commercial apps for startups and small companies. You will learn about my techniques and I will explain to you why those techniques work. This is a high-level talk, no code, but the process has never failed me.

The second talk starts at 10:45am in the same room as the first talk. This will be an "Introduction to Threading" talk for people new to threading. All code samples will use C# but the talk is not language specific. The information is relevant to any developer new to threading on a pre-emptive multitasking operating system.

So…if either of those sound interesting to you follow the Code Camp link and register.

9/28/2007

OnUserPreferenceChanged Hang

You think your code is clean and all is well in the world when all of a sudden your users are starting to report that your application is hanging. You research the issue and discover that from time to time your application hangs when it receives a WM_SETTINGCHANGE message or an OnUserPreferenceChanged event. Ivan Krivyakov did a very thorough write up of what's happening which you can find here. And Microsoft is supposed to have a knowledgebase article out soon about this.

We just ran into this problem and we have learned a few things beyond what Ivan presented. First…did you know that in .NET 2.0 when you create a Control or Form (window) object…it really doesn't exist? For performance reasons Microsoft delays the actual window creation until the window becomes visible or a handle request is made. On the surface this looks innocent enough but if you took the time to read Ivan's report you realize that the final action of window creation may NOT happen on the main UI thread. Where you probably started it.

And don't think you're going to get a CrossThreadException on this one. Even with the CheckForIllegalCrossThreadCalls flag set no exception was thrown. Nor was an exception thrown when the application encountered this problem outside the debugger. Which the documentation says should happen.

Ivan's Freezer code worked very well (he has a link on The Page for some code, you'll want that) and made it very easy for me to reproduce the problem. So step one whenever debugging something like this is to reproduce it on the developer's machine. Freezer enables just that.

Force Window Creation

One thing that Ivan's write-up didn't make clear to me was how to get around this problem. I have confirmed from the Microsoft support guy (Trevor) that the code below will work if you've identified the correct window.

You basically have to force the window creation and you can do that in one of two ways: 1) make the window visible with a Show() or 2) request the Handle. I used the code below:


List lstHandles = new List();
IntPtr hTemp;
foreach (Control myCtrl in Controls)
{
hTemp = myCtrl.Handle;
lstHandles.Add(hTemp);
}

hTemp = Handle;
lstHandles.Add(hTemp);
lstHandles.Clear();


I put the handles in a temporary buffer because I wasn't sure if the optimizing compiler would drop a simple assignment loop like this:


IntPtr hTemp;
foreach (Control myCtrl in Controls)
{
hTemp = myCtrl.Handle;
}

hTemp = Handle;


Identifying the Hanging Window

We had not correctly identified the problem Window. To do that we needed Trevor's suggestion which sent us down the correct road. Trevor suggested using Spy++ to identify what threads our windows were running on.

This was a new use case for me (with Spy++), I had already thrown Spy++ out as a tool for this problem because with Spy++ running the hang hung my entire desktop and nothing worked but the good old three finger salute, to get a Task Manager up.

The trick was to not start Spy++ until we were ready to run the test. So I got my application to the area I knew would hang (with the help of Freezer), and then started Spy++. Once in Spy++ you'll want to do the steps below to find that "bad" window:

1. Select Spy->Processes
2. In the Process dialog find your process
3. Expand your process
4. Expand the threads with the + sign
5. Look for GUI elements on those threads. If you find an element on a non-UI thread...you have found culprit.

You might think that it would be obvious and clear where all your windows are but that wasn't the case for us. Down in our audio code an engineer had created a window to pass to the SetCooperativeLevel(). This was the problem window. A window with no title…so we basically stepped through the process until we saw that Spy++ now contained a window on a non-UI thread.

What was interesting here is that the Window was actually created much earlier but only finished being created on the call to SetCooperativeLevel(). So once we discovered where the system thought the window was created we had to back up the callstack to find the actual window creation location.

8/17/2007

Can you hear me now? ... No

I've spent the last three days trying to figure out how we lost audio in our server products.

I had the following pieces of information:

1. We are using DirectSound.
2. The following DirectSound call threw the exception: ApplicationException. Of course…it's not documented for this constructor.

_captureBuffer = new CaptureBuffer(desc, device);

3. The following DirectSound call did not threw an exception, however VS2005 Watch window says that the Caps property threw a NullReferenceException. So basically I have an empty Caps property.

_captureDevice = new Capture();

4. I ran the DirectSound managed sample CaptureSound and that application had the same problems as I was having in my server application.

This all makes me start wondering about drivers and hardware…but the weird thing was the problem manifested at the same time on three servers.

While attempting to debug this problem I was using Microsoft's Remote Desktop to access the servers. It actually turns out that Remote Desktop is the problem.

To fix the problem:

1. Open Remote Desktop Connection. Enter the machine address and then select Options.
2. Select the Local Resources page and in the Remote computer sound group box select Leave at remote computer.
3. Select Connect.
4. Log in to your machine
5. Close the Remote Desktop session.

Can you hear me now? …Yes

8/06/2007

Didn't Microsoft used to have forums?

I just got to know what is going on? I haven't been able to access Microsoft forums for awhile now. I'm getting the error below when I try to link to http://forums.microsoft.com:



And if I try any link off the forums.microsoft.com root...such as the one in the right hand panel of the http://msdn2.microsoft.com page...under Communities...my browser just sits there spinning...looking lost and confused. In other words...nothing loads and there is no error message.

So Microsoft...WHAT'S UP!

7/28/2007

Grand Theft Auto – The Insurance Way

A few weeks ago my neighbor hit my truck. There is no question in any one's mind as to who is responsible. The truck was parked on the street in the same place it has been parked (when I'm home) for nine years. And…did I mention it was parked… as in not moving, stationary.

When it first happened I was angry…more for the inconvenience the accident represented than because I felt a victim. The damage wasn't too bad and I figured that the insurance company (he did stop and he had insurance) would take care of things. Boy was I wrong.

The insurance company (Progressive) has "valued" my truck at $3600 and decided that the repairs exceeded the value of the vehicle and totaled it. On the surface this seems logical but what it actually is, is an extremely unethical decision that moves me from someone who has simply been inconvenienced to a true victim. Progressive has given me the choice of $3600 where they take ownership of my truck and give me the money or I can keep my truck and $2700 (to fix it myself) with the stamp of "Salvage" added to the title. Neither option is acceptable.

I can not replace my truck for the pittance they have offered and the stamp of "Salvage" is a whole other head ache. This entire incident has left me without transportation and has eaten up a considerable amount of time, with more time to be lost in the future as I continue to search for a solution.

In 1993 I drove my truck off the lot, brand new, for fourteen years I have driven that vehicle. I know it and I feel safe in it. And now…what can I possibly buy for $3600 that could come close the value that truck has to me? The emotional side of my personality is screaming out at the injustice. "I DID NOTHING WRONG!" I believe that either Jeff (the guy who hit the truck) or his insurance company should pay to have my truck repaired. The fact that the market value of the vehicle is less that the repair costs SHOULD NOT BE my problem. The value of the truck to me can not be measured in a dollar amount.

I'm open to suggestions. I've already talked to my insurance company and pretty much got the same story. This is wrong. We wonder how the Enron and WorldCom scandals can happen…here is your answer. When our business communities measure the cost of something they RARELY stop to think about the human cost or the long-term costs. These nameless, faceless entities only consider the short-term bottom line...thus making it easy to dump toxic waste, rob from their employees and share holders, produce shoddy products, and steal from the people they are supposed to serve.

This picture should give you an idea of how long he had to slow down...



This is all the damage...really looks like the truck should be totaled right? It's drivable, just not legally drivable...





As you can see from the photos the truck is basically fine and the only one inconvenienced by any of this has been me and my family.