How to kill Mono program properly - c#

I'm currently working on a cross-platform app written in C#. I have a huge problem with testing and debugging it under Linux/Mono. When my application hangs due to an error, I have to kill the process (either using stop button in MonoDevelop debugger or using kill(all) command). The problem is, that after killing I cannot start the application again. When restarted from console, it waits a second or two and exits, showing nothing as output. When started from MonoDevelop, debugger loads some assemblies and then the process exits with no error. There seems to be no Mono-related service in process table. The only way to start the application again is to log off and log in again.
What I'm doing wrong?

Related

Resolving UWP Application Hangs

I built a UWP application which logs data from an internal class to a .csv file using the CSVHelper library. I am having a problem where the application stops responding when running in debug mode without any exceptions being thrown. The app also does not crash. In VS the diagnostic session timer is stopped but the code is still "running". There is no stack trace when I break, the application won't hit any breakpoints and closing the app with the "X" closes the window visually but it doesn't end the debugging session and I suspect the process remains running. I have to use the "Stop Debugging" button in visual studios to end the session. It occurs at seemingly random intervals unrelated to what the app is currently doing. The crashes are usually in the 50min+ execution time range though it has happened earlier.
How do I go about troubleshooting this issue?
I really don't know where to start without any exceptions or even a clue as to what causes the application to hit this state. I would include code but other than just linking the entire repo I am not sure which sections would actually be helpful as I don't know, nor can I seem to find a way to identify what code is running to enter this state.

WPF application process does not terminate

We wrote a wpf application using .NET 3.5. We use the CANopen protocal and log4net. The application starts a few tasks all of which are completed. I checked this by writing a message to the log file - everything was ok. Sometimes the application process terminates immediatelly, sommetimes it takes a few seconds and sometimes it does not terminate. Any ideas what could cause this?

Xamarin debugger terminates the app when using Branch.io

I am using the Branch.io Xamarin SDK in my iOS app.
From my FinishedLaunching method on the AppDelegate, I call this code as advised in the Branch documentation (https://github.com/BranchMetrics/Branch-Xamarin-SDK)
BranchIOS.Init(BranchKey, url, true);
Branch branch = Branch.GetInstance();
branch.InitSessionAsync(this);
If I run my code using the debugger (both on iPhone and iPhoneSimulator), the app terminates shortly afterwards, without any sort of error or exception printed in the logs. (There is an exception logged by Crashlytics in a log file, but I can't read it.) It is indeterminate when exactly the app terminates.
If I start the app without the debugger, Run -> Start Without Debugging, the app runs fine and does not terminate. Of course, if I remove the above 3 lines, the app runs fine under the debugger as well.
How do I go about getting a stack trace or some other log to find out why the app is terminating, and what is causing the app to terminate only while debugging?
I've read reports that when you switch between targets or toggle debugger on/off, you need to clean and rebuild before trying to run it. Otherwise, the pre-built files aren't applicable after switching. Have you tried this?

Program not closing properly on Linux

I have written an application on C#, and ported it onto Linux server (RHEL) using Mono and mkbundle. It works fine, but for some reason program is not closing properly. Right now there are over 30 instances of the program running in the background (according to task manager), although the program didn't return any error, and when it is running on windows or even Ubuntu VM it is working properly and closes without problems. What can be the reason? How can I ensure that program stops completely after execution is finished?

Mono & WInforms on OS X

I have just begun to explore the mono winforms environment and I cannot work out how to start a program from within monodevelop without a console session being started.
My simple program runs okay but when it exits a terminal session is always created & waiting for me to 'press any key'. I guess I could arrange things so that the terminal window closes automatically, but I would rather the app just ran 'natively', is this possible or does the way mono & .net function work preclude it?
As shown in the examples at Zetcode, in 'Main' the rest of the code is started with 'application.run(new aFunction());', I thought this might be the cause of the terminal session occurring but replacing it with:
myNewClass n = new myNewClass();
n.aFunction();
causes the program to not run at all (or maybe just exit without doing anything).
I am an experienced programmer but not familiar at all with C# or the mono/.net environment so 'stating the obvious' may be all that is required in an answer.
MonoDevelop will usually let you start a program with or without it running in an external console.
In MonoDevelop 2.8 on Linux you can control this by context clicking on a project in the solution tree and selecting Options; then Run on external console under the Run section. I'm not sure if you can disable this on OSX.

Categories