473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

OpenFileDialog hangs on Vista


I have just purchased a new Dell Windows Vista Home Premium SP1 system.

One of my .NET 2.0 programs doesn't work on it. I have reduced it to the
tiny program below which fails in the same way.

On My old XP system, this code dsplays the OpenFileDialog, I select a
file and it logs the filename to the console.

On my Vista system, the OpenFileDialog never displays and the program
hangs on the ShowDialog method.

Does anyone have any ideas what is the cause? Is it a Vista config issue?

I can't reinstall the .NET 2.0 runtime as it says it is already
installed. I can't see anywhere in CP/Programs to uninstall it!

Shouldn't this just work out-of-the-box?

Thanks,

Nick

using System.Windows.Forms;
using System;

public class Test {

public static int Main(string [] args) {
Console.WriteLine ("OpenFileDialog Test");
try {
OpenFileDialog ofd = new OpenFileDialog();
Console.WriteLine ("Ready to show dialog");
if(ofd.ShowDialog() == DialogResult.OK) {
Console.WriteLine ("Filename is {0}", ofd.FileName);
}
}
catch (Exception e) {
Console.WriteLine ("Exception is {0}", e.ToString());
}
return 0 ;
}
}
Oct 22 '08 #1
5 3640
The exception tells you how to fix the issue. You need simply to add
[STAThread] before your main routine.

"Nick Tatham" <nt******@nospam.comwrote in message
news:Xn*******************@216.196.109.145...
>
I have just purchased a new Dell Windows Vista Home Premium SP1 system.

One of my .NET 2.0 programs doesn't work on it. I have reduced it to the
tiny program below which fails in the same way.

On My old XP system, this code dsplays the OpenFileDialog, I select a
file and it logs the filename to the console.

On my Vista system, the OpenFileDialog never displays and the program
hangs on the ShowDialog method.

Does anyone have any ideas what is the cause? Is it a Vista config issue?

I can't reinstall the .NET 2.0 runtime as it says it is already
installed. I can't see anywhere in CP/Programs to uninstall it!

Shouldn't this just work out-of-the-box?

Thanks,

Nick

using System.Windows.Forms;
using System;

public class Test {

public static int Main(string [] args) {
Console.WriteLine ("OpenFileDialog Test");
try {
OpenFileDialog ofd = new OpenFileDialog();
Console.WriteLine ("Ready to show dialog");
if(ofd.ShowDialog() == DialogResult.OK) {
Console.WriteLine ("Filename is {0}", ofd.FileName);
}
}
catch (Exception e) {
Console.WriteLine ("Exception is {0}", e.ToString());
}
return 0 ;
}
}
Oct 22 '08 #2
add this line,

Application.Run(new Form());
return (0);
"Nick Tatham" <nt******@nospam.comдÈëÏûÏ¢
news:Xn*******************@216.196.109.145...
>
I have just purchased a new Dell Windows Vista Home Premium SP1 system.

One of my .NET 2.0 programs doesn't work on it. I have reduced it to the
tiny program below which fails in the same way.

On My old XP system, this code dsplays the OpenFileDialog, I select a
file and it logs the filename to the console.

On my Vista system, the OpenFileDialog never displays and the program
hangs on the ShowDialog method.

Does anyone have any ideas what is the cause? Is it a Vista config issue?

I can't reinstall the .NET 2.0 runtime as it says it is already
installed. I can't see anywhere in CP/Programs to uninstall it!

Shouldn't this just work out-of-the-box?

Thanks,

Nick

using System.Windows.Forms;
using System;

public class Test {

public static int Main(string [] args) {
Console.WriteLine ("OpenFileDialog Test");
try {
OpenFileDialog ofd = new OpenFileDialog();
Console.WriteLine ("Ready to show dialog");
if(ofd.ShowDialog() == DialogResult.OK) {
Console.WriteLine ("Filename is {0}", ofd.FileName);
}
}
catch (Exception e) {
Console.WriteLine ("Exception is {0}", e.ToString());
}
return 0 ;
}
}
Oct 22 '08 #3
The original post looked to be a console application to me.

"Leon" <am******@163.comwrote in message
news:D5**********************************@microsof t.com...
add this line,

Application.Run(new Form());
return (0);
"Nick Tatham" <nt******@nospam.comдÈëÏûÏ¢
news:Xn*******************@216.196.109.145...
>>
I have just purchased a new Dell Windows Vista Home Premium SP1 system.

One of my .NET 2.0 programs doesn't work on it. I have reduced it to the
tiny program below which fails in the same way.

On My old XP system, this code dsplays the OpenFileDialog, I select a
file and it logs the filename to the console.

On my Vista system, the OpenFileDialog never displays and the program
hangs on the ShowDialog method.

Does anyone have any ideas what is the cause? Is it a Vista config issue?

I can't reinstall the .NET 2.0 runtime as it says it is already
installed. I can't see anywhere in CP/Programs to uninstall it!

Shouldn't this just work out-of-the-box?

Thanks,

Nick

using System.Windows.Forms;
using System;

public class Test {

public static int Main(string [] args) {
Console.WriteLine ("OpenFileDialog Test");
try {
OpenFileDialog ofd = new OpenFileDialog();
Console.WriteLine ("Ready to show dialog");
if(ofd.ShowDialog() == DialogResult.OK) {
Console.WriteLine ("Filename is {0}", ofd.FileName);
}
}
catch (Exception e) {
Console.WriteLine ("Exception is {0}", e.ToString());
}
return 0 ;
}
}
Oct 22 '08 #4
The exception tells you how to fix the issue. You need simply to add
[STAThread] before your main routine.
Thanks Mike.

I never got an exception - it just hung. So I couldn't follow the message!
But adding this construct fixed the problem - and my original problem as
well.

It doesn't explain why it worked fine on XP but not on Vista though.

Thanks for you help,

Nick
Oct 23 '08 #5
Nick Tatham wrote:
>The exception tells you how to fix the issue. You need simply to add
[STAThread] before your main routine.

Thanks Mike.

I never got an exception - it just hung. So I couldn't follow the message!
But adding this construct fixed the problem - and my original problem as
well.

It doesn't explain why it worked fine on XP but not on Vista though.
You do have some network shares on Vista? Does a normal explorer open
without problems?

If you disable all network shares and remove all DVDs/CD's from drives
does it work then? (Just for testing)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Oct 23 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rajendra KASHI | last post by:
Hi, I am currently supporting one of the .Net application build with C# language. The application uses lots of delegates, in using the delegates the ShowDialog of the OpenDialogControl hangs the...
3
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access...
2
by: don | last post by:
has anyone experienced problems with interactions between OpenFileDialog and FileStream? When I select "open" from an OpenFileDialog the subsequent calls to FileStream do not create a file. If I do...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
8
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
6
by: barbara_dave | last post by:
Hi, All, I want to use the openfiledialog to open different extension files in different directory( only one type files at one time). I set the OpenFiledialog InitialDirectory and Filter...
13
by: Randall Arnold | last post by:
I'm not happy with the order in which OpenFileDialog retrieves multiple selected files. I want them in Date order, oldest to newest, but by default they come in by filename, last to first. The...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
5
by: Eric Promislow | last post by:
Here's a small Python program I use to grab the output from rake: ===== from subprocess import Popen, PIPE p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.