Re: Try...Catch across assemblies



Bryce Covert <BryceCovert@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

<snip>

> With this code, you will get a messagebox showing the error when run from
> VS. You will not from running outside.

Well, the good news is that it's got nothing to do with running in a
different assembly. The bad news is I don't entirely understand it. I
*believe* it's because when you show a dialog, it starts a new message
pump, and *that's* what is popping up the message box. I don't know how
to solve it though. It might be worth asking in the Windows Forms
newsgroup. Here's the code I used to reproduce it in the end in a more
compact (and readable to me, as a C# programmer :) form:

using System;
using System.Windows.Forms;

public class Test : Form
{
public Test()
{
Load += new EventHandler(LoadEventHandler);
}

private void LoadEventHandler(object sender, EventArgs args)
{
throw new Exception("Hello");
}

static void Main()
{
try
{
new Test().ShowDialog();
}
catch (Exception e)
{
Console.WriteLine ("Caught "+e);
}
}
}

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Unhandled Exceptions outside of VS
    ... Some of us on the .net framework were working on an issue that I've ... generate an unhandled exception. ... public class Test: Form ... private void LoadEventHandler ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: creating/copying files..
    ... with FileOutputStream and writing no bytes. ... private void makeFile(){ ...
    (comp.lang.java.help)
  • RE: checkboxcontrol does not work
    ... ASP.NET News: http://www.Kapoorsolutions.com/reblogger/ ... "Jimmy" wrote: ... > private void Button2_Click(object sender, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Roll your own std::vector ???
    ... news: eeOz1AfIHHA.4112@xxxxxxxxxxxxxxxxxxxxxxx ... Array.Copy(ia, temp, ia.Length); ... Joanna Carter [TeamB] ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Can’t copy to clipboard
    ... > at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy) ... Dennis ... private void btnCopyAddress_Click ...
    (microsoft.public.dotnet.framework)