views:

54

answers:

2

I have a winform, VBExpress 2008 with a single button and this code behind it to illustrate the problem:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Button1.Click
OpenFileDialog1.ShowDialog()
MsgBox(OpenFileDialog1.FileName)
End Sub

When I select a file (in my case small PDF's) I am getting a 3 to 6 second delay after selecting the file until it goes on to the next statement, in this case a MsgBox.

If I repeat selecting that same file a second time, I don't get the delay. But, if I exit the program and re-start it, then I do get the delay again (one time). After the first one hangs it looks like it hangs about ever 7 to 9 tries and the window says "not responding" for a few seconds. I don't have this problem on Vista or XP.

If I select the same file over and over, it might hang the 1st, 2nd and 12th time. Close program try same again, this might be the 1st, 3rd and 9th time. Never the same - as if it is running out of resources and clearing a cache.

I've watched the task manager during the delay and don't see anything unusual coming up. I have a new computer with everything operating properly. I thought maybe it was my Norton Internet Security -- but I turned that off and it made no difference.

Can anyone give me a clue what might be going on and/or how I might trace the source of the delay to the bottom of it? I've tried everything I know to isolate the problem and am running out of ideas. I don't see any other posts about this particular thing.

+1  A: 

Project + Properties, Debug tab, tick "Enable unmanaged code debugging". Run your program and select the Output window in VS. Open your dialog. What you see in the Output window are a crapload of unmanaged DLLs getting loaded into your process.

These are the shell extension handlers that are installed on your machine. The bad ones can affect your program in unpleasant ways, much like you describe in your question. Use SysInternals' AutoRuns utility to get control over this. Start by disabling the ones that were not made by Microsoft.

Hans Passant
Thx. Debug option above is not available on Express editions. Note that this is test project containing one form with a button and an openfiledialog control and the two lines of code I wrote above ONLY. How can just this load anything unexpected in my process? Why only on Win7 (or on this new machine)? I wouldn't know what to look for in AutoRuns that relate to this but I will try.
pghcpa
A: 

On MSDN suggestion was made to me -- remove network cable and see if problem disappears. It did.

I had two network connections to my old PC which was powered down. Removed those and it resolved the problem.

So, now the question is in vb.net winforms, how do you customize the Win7 OpenFileDialog box (standard win explorer box) to not display or be delayed by dormant network locations? Or, how do you prevent this in Win7. I will research and if necessary re-post that separately.

I really don't want to distribute my application with a warning that if you're on Win7 and have dormant network locations, you're going to get latency when choosing files.

pghcpa