Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Re: OpenFileDialog hangs on Vista

Reply
 
Old 10-22-2008   #1 (permalink)
Family Tree Mike


 
 

Re: OpenFileDialog hangs on Vista

The exception tells you how to fix the issue. You need simply to add
[STAThread] before your main routine.

"Nick Tatham" <ntatham1@xxxxxx> wrote in message
news:Xns9B3F607A7EFC7ntxnd@xxxxxx
Quote:

>
> 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 ;
> }
> }

My System SpecsSystem Spec
Old 10-22-2008   #2 (permalink)
Leon


 
 

Re: OpenFileDialog hangs on Vista

add this line,

Application.Run(new Form());
return (0);


"Nick Tatham" <ntatham1@xxxxxx> дÈëÏûÏ¢
news:Xns9B3F607A7EFC7ntxnd@xxxxxx
Quote:

>
> 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 ;
> }
> }
My System SpecsSystem Spec
Old 10-22-2008   #3 (permalink)
Family Tree Mike


 
 

Re: OpenFileDialog hangs on Vista

The original post looked to be a console application to me.

"Leon" <amoon.nj@xxxxxx> wrote in message
news5E2AE3B-AB93-4552-B809-62F1190DA377@xxxxxx
Quote:

> add this line,
>
> Application.Run(new Form());
> return (0);
>
>
> "Nick Tatham" <ntatham1@xxxxxx> дÈëÏûÏ¢
> news:Xns9B3F607A7EFC7ntxnd@xxxxxx
Quote:

>>
>> 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 ;
>> }
>> }
>
My System SpecsSystem Spec
Old 10-23-2008   #4 (permalink)
Nick Tatham


 
 

Re: OpenFileDialog hangs on Vista

> The exception tells you how to fix the issue. You need simply to add
Quote:

> [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


My System SpecsSystem Spec
Old 10-23-2008   #5 (permalink)
Frans Bouma [C# MVP]


 
 

Re: OpenFileDialog hangs on Vista

Nick Tatham wrote:
Quote:
Quote:

>> 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#)
------------------------------------------------------------------------
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
OpenFileDialog doesn't work with Framework 3.5 PowerShell
OpenFileDialog: Excluding Files .NET General
Vista hangs while I am away Vista General
Vista x64 hangs because of HD Vista hardware & devices
Vista Hangs Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46