|
-
July 21st, 2009, 03:32 AM
#1
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.
-
July 21st, 2009, 03:37 AM
#2
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")
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
July 21st, 2009, 04:30 AM
#3
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
-
July 21st, 2009, 04:36 AM
#4
Re: Use MessageBox without using Form's libraries
Yes, it works perfectly!
Thank you very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|