views:

639

answers:

3

I made a C# windows application in visual c# express 2008. I executed the exe file seperately on my PC and it worked perfectly.. Now when I ran the same file on another computer having vista an error occurred "WindowsFormapplication has stopped working". On my computer too it stops working after 5-10 min. So is the problem with my code or is it anything else?

I am a newbie here... Any help would be appreciated..

Edited.....

It uses timers:

System.Timers.Timer timer = new System.Timers.Timer();
timer.Elapsed += new ElapsedEventHandler(startup.onTimerEvent);
timer.AutoReset = true;
timer.Interval = 60000;
timer.Start();
Application.Run();
GC.KeepAlive(timer);

It also creates and sets a registry key..

A: 

Could you be using something from a version of .NET that is not available on the second machine?

Niklas
+2  A: 

I'm guessing it is a permissions issue. On Vista the system is locked down tighter so if your program couldn't get the permission it needed it will throw an exception. If that happens at the start of the program that's why you get the error on start up.

On your own machine you may be waiting 5-10 minutes because it is a different bug that is causing the application to fail.

Colin Mackay
Just to add now you've mentioned HKEY_LOCAL_MACHINE - This requires admin rights. If you don't have them an exception will be thrown. On Vista even if you are logged on as admin you need to elevate your privileges to run as Admin.
Colin Mackay
Thank you Colin.. I will work on that aspect of programming
5lackp1x3l0x17
A: 

I agree with Colin. Sounds like it is no doubt a permission issue when your application is trying to create the Registry Key.

You should have a wrapper which checks the user has permissions before attempting to write, or at least handles if the user does not...

James
Yes Thank you too..
5lackp1x3l0x17