Reputation: 36223
I am currently working on a c# linux application being run under mono. Although, I believe I've handled any possible exceptions that might be thrown within my program, but should I have missed any, I was wondering if there is a way that when the C# application crashes it creates a core dump file so I can see the exception and go through it to try and determine what caused the problem like GDB does for C programs.
I'm using OpenSuse 12.1 for my application.
Thanks for any help you can provide.
Upvotes: 6
Views: 3929
Reputation: 65594
Sounds like you want a SuperAssert for Mono. I could only find this Mono mail thread. They discuss the possible conversion of the Managed Debugger to Mono. Unfortunately the Microsoft EULA appears to have prevented them from porting this one. Therefore it looks like you'll need to use the Operating System directly. Here is the official guide on how you capture a core dump
The following steps should be taken to prepare for capturing a core dump:
-Disable the limit for the maximum size of a core dump file
-Configure a fixed location for storing core dumps
-Disable AppArmor
-Enable core dumps for setuid and setgid processes
The quick step guide for this is as follows:
Run
ulimit -c unlimited
Run
install -m 1777 -d /var/local/dumps
Run
echo "/var/local/dumps/core.%e.%p"> /proc/sys/kernel/core_pattern
Run
rcapparmor stop
Run
sysctl -w kernel.suid_dumpable=2
(Re)start problematic processes.
Also take a look at this thread: Core dump in Linux - if you think the app might crash, maybe you could setup a technical support helper script/exe to perform all the above actions and launch the Mono application. This would make it easy for end user to reproduce the problem and send you the dump to diagnose the problem.
Upvotes: 1
Reputation: 1186
Yes, you can, but you can only find out what .NET exception
happened, dunno if you can do a core dump without third-party softwere though.
Depending on the type of the application you can hook one of the following events
:
if you use Windows Forms Application
you could subscribe to System.Windows.Forms.Application.ThreadException
if you use WPF
you could subscribe to System.Windows.Threading.Dispatcher UnhandledException
if you want to subscribe to a general UnhandledException
event, you could subscribe to System.AppDomain.UnhandledException
(but I guess if the application don't have enough access can't access this event).
Upvotes: 0
Reputation: 11249
Have you seen the following?
http://www.mono-project.com/Debugging#Debugging_with_GDB
Upvotes: 0