I have a problem. When I use app it works good. But when I get called while using my application or I use another applications (browser, office, etc) WITHOUT CLOSING the application I am developing, when I try to use it again, it crashes. But if I close it and try to launch, it works fine. How can I solve this problem?
To debug this, you need to understand what's happening.
When an application gets hidden by another one, it goes through different lifecycle stages than it does from a new launch.
You must be depending on some initialization that's happening during the regular launch lifecycle stages.
This could be for several reasons. Maybe your app cleans something up when it gets hidden, that isn't reinitialized when it's visible again, for example.
I solved my crash using shared preferences. System Android cleaned all values from variables. So it caused crash. Now all values are stored in Shared Preferences and nothing losses and the app works stable.
Related
I made a program, which works fine on my PC without any errors, it also works fine on some office PCs, but it crashes without any describable error on customer's PC and some others.
Crashes are completely random, sometime it may crash and sometimes not.
Crashes are not related with any actions, sometimes it may crash when they just look at the program and wait for crash.
Customers send me this beautiful screens and want me to solve this.
There you see common error reporting dialog, but not info about Exception.
My program uses Unity Web Player running in WebBrowser control. It's always run in background on the hidden tab which becomes visible when needed.
Any ideas how to handle such errors?
I think you should first ensure that the environment at your place and that of your customers are identical.
Maybe there're dll or other programs installed at your place (Unity web player as you mentioned for example) or anything in your Registry that may differ.
Else there's no point in getting error on one PC and not on another.
Make sure all dll are well deployed
Check your registry,
Ensure that all related programs are well installed
I am writing a small utility application to monitor my clipboard. This at current works quite well, but a friend has told me that it randomly will stop showing alerts upon clipboard change, and that restarting fixes it.
I couldn't reproduce, but eventually I ran into it myself - the application had stopped recieving WM_DRAWCLIPBOARD events.
How can I tell when my application has been removed from the listener chain?
This is one of the hazards of the clipboard listener chain: One bad application can damage the chain. Instead of using the SetClipboardViewer function, use AddClipboardFormatListener which does not have this problem.
If you are debugging an application that uses SetClipboardViewer and the application crashes or you stop the application in the debugger, or in some other way bypass the restoration of the clipboard chain, there is performance degradation in Windows, to the point that seemingly unrelated features of Windows, such as Alt-Tab, or restoring a minimized window, stop working. They come back if you restart Windows.
An application that inserts itself into the clipboard chain this way should be calling ChangeClipboardChain during Dispose of the main form, or at another appropriate time, to avoid this issue. Dispose isn't called if you stop the app in the debugger.
I have not tried AddClipboardFormatListener; first time I've heard of it; I'm going to try it to see if I can avoid the issue in my own app while I'm debugging.
I've never seen this issue before, and I'm not even sure if I'm posting in the correct place.
My Co-worker wrote a C# program (windows), that includes a web control. In that web control are a bunch of iFrames. Now, when the web control is populated (max 15 records), everything is fine. 99% system idle process. But once you minimize the program, boom, 99% process goes to the c# program and stays there!
If the web control is not populated. There is no issue with minimizing and maximizing the program.
There are no functions that run when the program is minimized or maximized, so there's nothing to debug...
The program is crashing on two computers, but on the rest (about 8 computers) it runs fine.
The two computers that "crash", are not very similar... so it's proving hard to find what may be causing the issue. One computer is xp, the other is windows 7, one is ie7, the other is ie8.
If anyone could point me in the right direction, or if anyone had a similar situation and has a solution, I'm all ear's and eye's!
I would attach Visual Studio to the "99% CPU" process, break all, and see what's going on in there. That's first step.
Doesn't Windows write inactive (i.e. minimised) application state to disk, to free up resources for active (non-minimised) windows?
One of the hooks / events called when you minimise the application could be causing IO hangs. You should get a diagnostics tool like Sysinternals Procmon to see if IO (or any other process) is hanging based on the minimise event.
Good luck!
Chris.
So my co-worker didn't find the thorough answer as to why it was crashing, but it was crashing due to the .net Web control. He swapped out the control for a VB6 control and it now works.
I am writing a C# app that has a main window and a separate login window. I set a DispatcherTimer to open a new login window if the user is idle for a certain period of time.
My app is crashing when i call .Close() on the login window. However, if I remove the DispatcherTimer code it works fine. Is System.Timers.Timer a better choice for this or is there something else I maybe doing wrong?
The strange part is the app doesn't crash and works fine when I run it in Visual Studio, but crashes when i Install it then run it.
Thanks,
Matt
Edit: I just tried installing it on my machine it works fine, but will break when installed on a client machine. Not sure why this would happen.. Maybe a missing dependency in the setup project? Thanks for your posts guys.
Breaking on all thrown exceptions may allow you to get a call stack for the problem. Go to "Exceptions..." in the Debug menu, and check all of the checkboxes in the "thrown" column.
You will probably want to undo this after you are done testing because it will break even on exceptions handled correctly by the application.
I have a WPF application that occasionally crashes, and say "not responding". Is there a way to detect if the program is not responding? And if so, restart the WPF application?
This will be a temporary fix until the bugs are fixed.
You could use the Application Recovery & Restart Manager API, which was introduced in Windows Vista. This is an unmanaged (C) API, however there are managed wrappers available in the Windows API Code Pack.
This is a good feature to add to your application anyway, as it provides the user with a nicer experience if (when!) you application crashes. You can even write a callback that persists information about what the user was doing, and then restore that state when the application restarts.
The most basic use of the API would be to just add the following line somewhere in application startup:
ApplicationRestartRecoveryManager.RegisterForApplicationRestart( new RestartSettings( "restart", RestartRestrictions.None ) );
Because this is a temporary fix while you debug the app, one possibility is to cheat and use a bootstrapper/startup app whose sole job is to monitor the problematic app. Start the problematic application via the System.Diagnostics.Process class's Start method, then occasionally monitor the returned Process' Responding property. If not responding, do what you need to do.
It's important that this only be done as a stopgap while you fix the real problem, of course. There are lots of little issues with doing something like this long-term.