开发者

C# - Application crashes on start up (Windows 7)

I am working on a project that must be run at Windows start up,

I have tried to use:

            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersio开发者_StackOverflow中文版n\\Run", true);
            rkApp.SetValue("1234", path + @"\xxxx.exe");
            rkApp.Close();

It starts with Windows but crashes immediately ("application has stopped working windows is checking...".

When I try to debug it, it doesn't crash.

How can I resolve it?


Don't guess at this, write code that helps you diagnose unhandled exceptions. Write an event handler for the AppDomain.CurrentDomain.UnhandledException event and log or display the value of e.ExceptionObject.ToString(). The stack trace you'll get will help you quickly diagnose the cause. I would guess at your code bombing because the app's default directory is not set where it is when you debug. Use full path names for files (i.e c:\foo\bar.txt, not bar.txt).


check if you have delay timer to keep the service running. If there is no work for the service, it will start and stop immediately. Try to log events into eventlogger.


Access to the registry is under security control. Check that the branch that you are posting to is writeable for the user that your application is running as.


"Application Crashing" means you have an unhandled exception %90 of the time. You need to log what that exception is to have any hope of solving this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜