Use MessageBox without using Form's libraries
Hi guys,
I need show an exception with a MessageBox but it take place in one project which mustn't use Form libraries. Maybe something like this.
Code:
public static void Main()
{
try
{
hallo(4);
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show(ex);
}
}
public static int hallo(int i)
{
int a;
try
{
int[] hola = {1, 2, 3};
a = hola[i];
}
catch (Exception ex){ throw ex; }
return a;
}
Thank you in advance.
Re: Use MessageBox without using Form's libraries
If you want to show a MessageBox, use the System.Windows.Forms library, that's why it's there. If you can't use that library, then don't use a MessageBox. You'll just end up duplicating (probably incorrectly) a load of code in System.Window.Forms just to emulate the single line: MessageBox.Show ("blah")
Re: Use MessageBox without using Form's libraries
You could try to use the MessageBox API. But even that would also be an overkill. still worth a shot though :)
Re: Use MessageBox without using Form's libraries
Yes, it works perfectly!
Thank you very much.