Undebuggable – who is killing my app?

time to read 1 min | 142 words

Here is an interesting problem that I have no solution for so far.

class Program
{
	static void Main(string[] args)
	{
		var foo = new Important();
		try
		{
			AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
			{
				Console.WriteLine(eventArgs.ExceptionObject);
			};
			using (var backend = new BackendBridge())
			{
				backend.Start(23321);

				string filePath = @"E:\Samples\blob.nhprof";
				using (var stream = File.OpenRead(filePath))
				{
					backend.LoadFromFile(stream, new CancellationToken());
				}
			}
			Console.WriteLine(foo);
		}
		catch (Exception e)
		{
			Console.WriteLine(e);
		}
		finally
		{
			Console.WriteLine("Done!");
		}
	}

	private class Important : CriticalFinalizerObject
	{
		~Important()
		{
			Console.WriteLine("finalized");
		}
	}
}

The problem is quite simple, reading the file will kill the application. The problem? I don’t know why.

The only output from the program is “finalized”, which suggest that there is something really nasty going on there. I am open for suggestions, because I have no idea how to deal with this thing, to tell you the truth.