![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | Re: OpenFileDialog hangs on Vista The original post looked to be a console application to me. "Leon" <amoon.nj@xxxxxx> wrote in message news 5E2AE3B-AB93-4552-B809-62F1190DA377@xxxxxxQuote: > 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 Specs![]() |
| | #4 (permalink) |
| | 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. 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 Specs![]() |
| | #5 (permalink) |
| | 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. 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 Specs![]() |
![]() |
| 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 | |||