.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Personalized Error MessageBox

4 REPLIES 4
Reply
Message 1 of 5
fmarcelino
222 Views, 4 Replies

Personalized Error MessageBox

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
4 REPLIES 4
Message 2 of 5
fmarcelino
in reply to: fmarcelino

Please help, i need a solution for this task guys...
Message 3 of 5
fmarcelino
in reply to: fmarcelino

hi again,

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

Thanks,
Filipe Marcelino
Message 4 of 5
ecarreras
in reply to: fmarcelino

Hi, did you get the problem solved? I'm trying to do the same.


Thanks,
Message 5 of 5
JamieVJohnson
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost