.NET

Reply
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 1 of 5 (89 Views)

Personalized Error MessageBox

89 Views, 4 Replies
01-13-2006 08:03 AM
Hi,

I developed a personalized error messagebox in C#. In a normal WindowsApplication to catch all the possible exceptions generated by that application I need to do:

public frmMainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyExceptionMessageBox.Show);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(MyExceptionMessageBox.Show);
}

Now, I developed a pallete to AutoCAD using C# to. My question is, how can I redirect all Exceptions generated by my application to MyExceptionMessageBox like I do in Windows Forms.

Thanks in advance for your attention,
Filipe Marcelino Message was edited by: fmarcelino
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 2 of 5 (89 Views)

Re: Personalized Error MessageBox

01-18-2006 02:26 AM in reply to: fmarcelino
Please help, i need a solution for this task guys...
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 3 of 5 (89 Views)

Re: Personalized Error MessageBox

01-20-2006 03:35 AM in reply to: fmarcelino
hi again,

does anyone need some kind of explanation? Am I not being clear?

Thanks,
Filipe Marcelino
New Member
ecarreras
Posts: 1
Registered: ‎03-24-2009
Message 4 of 5 (89 Views)

Re: Personalized Error MessageBox

03-24-2009 07:41 AM in reply to: fmarcelino
Hi, did you get the problem solved? I'm trying to do the same.


Thanks,
Distinguished Contributor
JamieVJohnson
Posts: 136
Registered: ‎09-29-2008
Message 5 of 5 (89 Views)

Re: Personalized Error MessageBox

03-26-2009 06:16 AM in reply to: fmarcelino


Well in VB.Net, we use Try/Catch blocks to redirect any errors to a central handler. Looks something like this...



Try

Normal use code

More normal code

Error Prone code

More normal code

Catch ex as System.Exception

HandleError(ex)

'or even this line: Dim aex as New System.Exception("Error Prone code sucks: ", ex)

'then toss the new error back out: Throw aex

'that causes the next routine up, to recieve the error, so that it can hand it off to HandleError(ex)

End Try



Then my main error handling routine HandleError(byval ex as System.Exception) takes care of the message box.



how ever, EVERY routine that starts something needs to have a try catch block to capture these errors.



jvj

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.