C# application stopped working

a 夏天 提交于 2019-12-11 16:57:48

问题


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


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/1129883/c-sharp-application-stopped-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!